home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / perl5 / CGI.z / CGI
Encoding:
Text File  |  2002-10-03  |  145.4 KB  |  3,499 lines

  1.  
  2.  
  3.  
  4. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      CGI - Simple Common Gateway Interface Class
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.        # CGI script that creates a fill-out form
  13.        # and echoes back its values.
  14.  
  15.        use CGI qw/:standard/;
  16.        print header,
  17.              start_html('A Simple Example'),
  18.              h1('A Simple Example'),
  19.              start_form,
  20.              "What's your name? ",textfield('name'),p,
  21.              "What's the combination?", p,
  22.              checkbox_group(-name=>'words',
  23.                             -values=>['eenie','meenie','minie','moe'],
  24.                             -defaults=>['eenie','minie']), p,
  25.              "What's your favorite color? ",
  26.              popup_menu(-name=>'color',
  27.                         -values=>['red','green','blue','chartreuse']),p,
  28.              submit,
  29.              end_form,
  30.              hr;
  31.  
  32.         if (param()) {
  33.             print "Your name is",em(param('name')),p,
  34.                   "The keywords are: ",em(join(", ",param('words'))),p,
  35.                   "Your favorite color is ",em(param('color')),
  36.                   hr;
  37.         }
  38.  
  39.  
  40. AAAABBBBSSSSTTTTRRRRAAAACCCCTTTT
  41.      This perl library uses perl5 objects to make it easy to create Web fill-
  42.      out forms and parse their contents.  This package defines CGI objects,
  43.      entities that contain the values of the current query string and other
  44.      state variables.  Using a CGI object's methods, you can examine keywords
  45.      and parameters passed to your script, and create forms whose initial
  46.      values are taken from the current query (thereby preserving state
  47.      information).  The module provides shortcut functions that produce
  48.      boilerplate HTML, reducing typing and coding errors. It also provides
  49.      functionality for some of the more advanced features of CGI scripting,
  50.      including support for file uploads, cookies, cascading style sheets,
  51.      server push, and frames.
  52.  
  53.      CGI.pm also provides a simple function-oriented programming style for
  54.      those who don't need its object-oriented features.
  55.  
  56.      The current version of CGI.pm is available at
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  71.  
  72.  
  73.  
  74.        http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html
  75.        ftp://ftp-genome.wi.mit.edu/pub/software/WWW/
  76.  
  77.  
  78. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  79.      PPPPRRRROOOOGGGGRRRRAAAAMMMMMMMMIIIINNNNGGGG SSSSTTTTYYYYLLLLEEEE
  80.  
  81.      There are two styles of programming with CGI.pm, an object-oriented style
  82.      and a function-oriented style.  In the object-oriented style you create
  83.      one or more CGI objects and then use object methods to create the various
  84.      elements of the page.  Each CGI object starts out with the list of named
  85.      parameters that were passed to your CGI script by the server.  You can
  86.      modify the objects, save them to a file or database and recreate them.
  87.      Because each object corresponds to the "state" of the CGI script, and
  88.      because each object's parameter list is independent of the others, this
  89.      allows you to save the state of the script and restore it later.
  90.  
  91.      For example, using the object oriented style, here is now you create a
  92.      simple "Hello World" HTML page:
  93.  
  94.         #!/usr/local/bin/pelr
  95.         use CGI;                             # load CGI routines
  96.         $q = new CGI;                        # create new CGI object
  97.         print $q->header,                    # create the HTTP header
  98.               $q->start_html('hello world'), # start the HTML
  99.               $q->h1('hello world'),         # level 1 header
  100.               $q->end_html;                  # end the HTML
  101.  
  102.      In the function-oriented style, there is one default CGI object that you
  103.      rarely deal with directly.  Instead you just call functions to retrieve
  104.      CGI parameters, create HTML tags, manage cookies, and so on.  This
  105.      provides you with a cleaner programming interface, but limits you to
  106.      using one CGI object at a time.  The following example prints the same
  107.      page, but uses the function-oriented interface.  The main differences are
  108.      that we now need to import a set of functions into our name space
  109.      (usually the "standard" functions), and we don't need to create the CGI
  110.      object.
  111.  
  112.         #!/usr/local/bin/pelr
  113.         use CGI qw/:standard/;           # load standard CGI routines
  114.         print header,                    # create the HTTP header
  115.               start_html('hello world'), # start the HTML
  116.               h1('hello world'),         # level 1 header
  117.               end_html;                  # end the HTML
  118.  
  119.      The examples in this document mainly use the object-oriented style.  See
  120.      HOW TO IMPORT FUNCTIONS for important information on function-oriented
  121.      programming in CGI.pm
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  137.  
  138.  
  139.  
  140.      CCCCAAAALLLLLLLLIIIINNNNGGGG CCCCGGGGIIII....PPPPMMMM RRRROOOOUUUUTTTTIIIINNNNEEEESSSS
  141.  
  142.      Most CGI.pm routines accept several arguments, sometimes as many as 20
  143.      optional ones!  To simplify this interface, all routines use a named
  144.      argument calling style that looks like this:
  145.  
  146.         print $q->header(-type=>'image/gif',-expires=>'+3d');
  147.  
  148.      Each argument name is preceded by a dash.  Neither case nor order matters
  149.      in the argument list.  -type, -Type, and -TYPE are all acceptable.  In
  150.      fact, only the first argument needs to begin with a dash.  If a dash is
  151.      present in the first argument, CGI.pm assumes dashes for the subsequent
  152.      ones.
  153.  
  154.      You don't have to use the hyphen at allif you don't want to.  After
  155.      creating a CGI object, call the uuuusssseeee____nnnnaaaammmmeeeedddd____ppppaaaarrrraaaammmmeeeetttteeeerrrrssss(((()))) method with a
  156.      nonzero value.  This will tell CGI.pm that you intend to use named
  157.      parameters exclusively:
  158.  
  159.         $query = new CGI;
  160.         $query->use_named_parameters(1);
  161.         $field = $query->radio_group('name'=>'OS',
  162.                                      'values'=>['Unix','Windows','Macintosh'],
  163.                                      'default'=>'Unix');
  164.  
  165.      Several routines are commonly called with just one argument.  In the case
  166.      of these routines you can provide the single argument without an argument
  167.      name.  _h_e_a_d_e_r() happens to be one of these routines.  In this case, the
  168.      single argument is the document type.
  169.  
  170.         print $q->header('text/html');
  171.  
  172.      Other such routines are documented below.
  173.  
  174.      Sometimes named arguments expect a scalar, sometimes a reference to an
  175.      array, and sometimes a reference to a hash.  Often, you can pass any type
  176.      of argument and the routine will do whatever is most appropriate.  For
  177.      example, the _p_a_r_a_m() routine is used to set a CGI parameter to a single
  178.      or a multi-valued value.  The two cases are shown below:
  179.  
  180.         $q->param(-name=>'veggie',-value=>'tomato');
  181.         $q->param(-name=>'veggie',-value=>'[tomato','tomahto','potato','potahto']);
  182.  
  183.      A large number of routines in CGI.pm actually aren't specifically defined
  184.      in the module, but are generated automatically as needed.  These are the
  185.      "HTML shortcuts," routines that generate HTML tags for use in
  186.      dynamically-generated pages.  HTML tags have both attributes (the
  187.      attribute="value" pairs within the tag itself) and contents (the part
  188.      between the opening and closing pairs.)  To distinguish between
  189.      attributes and contents, CGI.pm uses the convention of passing HTML
  190.      attributes as a hash reference as the first argument, and the contents,
  191.      if any, as any subsequent arguments.  It works out like this:
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  203.  
  204.  
  205.  
  206.         Code                           Generated HTML
  207.         ----                           --------------
  208.         h1()                           <H1>
  209.         h1('some','contents');         <H1>some contents</H1>
  210.         h1({-align=>left});            <H1 ALIGN="LEFT">
  211.         h1({-align=>left},'contents'); <H1 ALIGN="LEFT">contents</H1>
  212.  
  213.      HTML tags are described in more detail later.
  214.  
  215.      Many newcomers to CGI.pm are puzzled by the difference between the
  216.      calling conventions for the HTML shortcuts, which require curly braces
  217.      around the HTML tag attributes, and the calling conventions for other
  218.      routines, which manage to generate attributes without the curly brackets.
  219.      Don't be confused.  As a convenience the curly braces are optional in all
  220.      but the HTML shortcuts.  If you like, you can use curly braces when
  221.      calling any routine that takes named arguments.  For example:
  222.  
  223.         print $q->header( {-type=>'image/gif',-expires=>'+3d'} );
  224.  
  225.      If you use the ----wwww switch, you will be warned that some CGI.pm argument
  226.      names conflict with built-in Perl functions.  The most frequent of these
  227.      is the -values argument, used to create multi-valued menus, radio button
  228.      clusters and the like.  To get around this warning, you have several
  229.      choices:
  230.  
  231. -value is an alias for -values.
  232.      1. Use another name for the argument, if one is available.  For example,
  233.  
  234.      2. Change the capitalization, e.g. -Values
  235.  
  236.      3. Put quotes around the argument name, e.g. '-values'
  237.  
  238.      Many routines will do something useful with a named argument that it
  239.      doesn't recognize.  For example, you can produce non-standard HTTP header
  240.      fields by providing them as named arguments:
  241.  
  242.        print $q->header(-type  =>  'text/html',
  243.                         -cost  =>  'Three smackers',
  244.                         -annoyance_level => 'high',
  245.                         -complaints_to   => 'bit bucket');
  246.  
  247.      This will produce the following nonstandard HTTP header:
  248.  
  249.         HTTP/1.0 200 OK
  250.         Cost: Three smackers
  251.         Annoyance-level: high
  252.         Complaints-to: bit bucket
  253.         Content-type: text/html
  254.  
  255.      Notice the way that underscores are translated automatically into
  256.      hyphens.  HTML-generating routines perform a different type of
  257.      translation.
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  269.  
  270.  
  271.  
  272.      This feature allows you to keep up with the rapidly changing HTTP and
  273.      HTML "standards".
  274.  
  275.      CCCCRRRREEEEAAAATTTTIIIINNNNGGGG AAAA NNNNEEEEWWWW QQQQUUUUEEEERRRRYYYY OOOOBBBBJJJJEEEECCCCTTTT ((((OOOOBBBBJJJJEEEECCCCTTTT----OOOORRRRIIIIEEEENNNNTTTTEEEEDDDD SSSSTTTTYYYYLLLLEEEE))))::::
  276.  
  277.           $query = new CGI;
  278.  
  279.      This will parse the input (from both POST and GET methods) and store it
  280.      into a perl5 object called $query.
  281.  
  282.      CCCCRRRREEEEAAAATTTTIIIINNNNGGGG AAAA NNNNEEEEWWWW QQQQUUUUEEEERRRRYYYY OOOOBBBBJJJJEEEECCCCTTTT FFFFRRRROOOOMMMM AAAANNNN IIIINNNNPPPPUUUUTTTT FFFFIIIILLLLEEEE
  283.  
  284.           $query = new CGI(INPUTFILE);
  285.  
  286.      If you provide a file handle to the _n_e_w() method, it will read parameters
  287.      from the file (or STDIN, or whatever).  The file can be in any of the
  288.      forms describing below under debugging (i.e. a series of newline
  289.      delimited TAG=VALUE pairs will work).  Conveniently, this type of file is
  290.      created by the _s_a_v_e() method (see below).  Multiple records can be saved
  291.      and restored.
  292.  
  293.      Perl purists will be pleased to know that this syntax accepts references
  294.      to file handles, or even references to filehandle globs, which is the
  295.      "official" way to pass a filehandle:
  296.  
  297.          $query = new CGI(\*STDIN);
  298.  
  299.      You can also initialize the CGI object with a FileHandle or IO::File
  300.      object.
  301.  
  302.      If you are using the function-oriented interface and want to initialize
  303.      CGI state from a file handle, the way to do this is with
  304.      rrrreeeessssttttoooorrrreeee____ppppaaaarrrraaaammmmeeeetttteeeerrrrssss(((()))).  This will (re)initialize the default CGI object
  305.      from the indicated file handle.
  306.  
  307.          open (IN,"test.in") || die;
  308.          restore_parameters(IN);
  309.          close IN;
  310.  
  311.      You can also initialize the query object from an associative array
  312.      reference:
  313.  
  314.          $query = new CGI( {'dinosaur'=>'barney',
  315.                             'song'=>'I love you',
  316.                             'friends'=>[qw/Jessica George Nancy/]}
  317.                          );
  318.  
  319.      or from a properly formatted, URL-escaped query string:
  320.  
  321.          $query = new CGI('dinosaur=barney&color=purple');
  322.  
  323.      or from a previously existing CGI object (currently this clones the
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  335.  
  336.  
  337.  
  338.      parameter list, but none of the other object-specific fields, such as
  339.      autoescaping):
  340.  
  341.          $old_query = new CGI;
  342.          $new_query = new CGI($old_query);
  343.  
  344.      To create an empty query, initialize it from an empty string or hash:
  345.  
  346.         $empty_query = new CGI("");
  347.  
  348.             -or-
  349.  
  350.         $empty_query = new CGI({});
  351.  
  352.  
  353.      FFFFEEEETTTTCCCCHHHHIIIINNNNGGGG AAAA LLLLIIIISSSSTTTT OOOOFFFF KKKKEEEEYYYYWWWWOOOORRRRDDDDSSSS FFFFRRRROOOOMMMM TTTTHHHHEEEE QQQQUUUUEEEERRRRYYYY::::
  354.  
  355.           @keywords = $query->keywords
  356.  
  357.      If the script was invoked as the result of an <ISINDEX> search, the
  358.      parsed keywords can be obtained as an array using the _k_e_y_w_o_r_d_s() method.
  359.  
  360.      FFFFEEEETTTTCCCCHHHHIIIINNNNGGGG TTTTHHHHEEEE NNNNAAAAMMMMEEEESSSS OOOOFFFF AAAALLLLLLLL TTTTHHHHEEEE PPPPAAAARRRRAAAAMMMMEEEETTTTEEEERRRRSSSS PPPPAAAASSSSSSSSEEEEDDDD TTTTOOOO YYYYOOOOUUUURRRR SSSSCCCCRRRRIIIIPPPPTTTT::::
  361.  
  362.           @names = $query->param
  363.  
  364.      If the script was invoked with a parameter list (e.g.
  365.      "name1=value1&name2=value2&name3=value3"), the _p_a_r_a_m() method will return
  366.      the parameter names as a list.  If the script was invoked as an <ISINDEX>
  367.      script, there will be a single parameter named 'keywords'.
  368.  
  369.      NOTE: As of version 1.5, the array of parameter names returned will be in
  370.      the same order as they were submitted by the browser.  Usually this order
  371.      is the same as the order in which the parameters are defined in the form
  372.      (however, this isn't part of the spec, and so isn't guaranteed).
  373.  
  374.      FFFFEEEETTTTCCCCHHHHIIIINNNNGGGG TTTTHHHHEEEE VVVVAAAALLLLUUUUEEEE OOOORRRR VVVVAAAALLLLUUUUEEEESSSS OOOOFFFF AAAA SSSSIIIINNNNGGGGLLLLEEEE NNNNAAAAMMMMEEEEDDDD PPPPAAAARRRRAAAAMMMMEEEETTTTEEEERRRR::::
  375.  
  376.          @values = $query->param('foo');
  377.  
  378.                    -or-
  379.  
  380.          $value = $query->param('foo');
  381.  
  382.      Pass the _p_a_r_a_m() method a single argument to fetch the value of the named
  383.      parameter. If the parameter is multivalued (e.g. from multiple selections
  384.      in a scrolling list), you can ask to receive an array.  Otherwise the
  385.      method will return a single value.
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  401.  
  402.  
  403.  
  404.      SSSSEEEETTTTTTTTIIIINNNNGGGG TTTTHHHHEEEE _V_A_L_U_E(S) OF A NAMED PARAMETER:
  405.  
  406.          $query->param('foo','an','array','of','values');
  407.  
  408.      This sets the value for the named parameter 'foo' to an array of values.
  409.      This is one way to change the value of a field AFTER the script has been
  410.      invoked once before.  (Another way is with the -override parameter
  411.      accepted by all methods that generate form elements.)
  412.  
  413.      _p_a_r_a_m() also recognizes a named parameter style of calling described in
  414.      more detail later:
  415.  
  416.          $query->param(-name=>'foo',-values=>['an','array','of','values']);
  417.  
  418.                                    -or-
  419.  
  420.          $query->param(-name=>'foo',-value=>'the value');
  421.  
  422.  
  423.      AAAAPPPPPPPPEEEENNNNDDDDIIIINNNNGGGG AAAADDDDDDDDIIIITTTTIIIIOOOONNNNAAAALLLL VVVVAAAALLLLUUUUEEEESSSS TTTTOOOO AAAA NNNNAAAAMMMMEEEEDDDD PPPPAAAARRRRAAAAMMMMEEEETTTTEEEERRRR::::
  424.  
  425.         $query->append(-name=>'foo',-values=>['yet','more','values']);
  426.  
  427.      This adds a value or list of values to the named parameter.  The values
  428.      are appended to the end of the parameter if it already exists.  Otherwise
  429.      the parameter is created.  Note that this method only recognizes the
  430.      named argument calling syntax.
  431.  
  432.      IIIIMMMMPPPPOOOORRRRTTTTIIIINNNNGGGG AAAALLLLLLLL PPPPAAAARRRRAAAAMMMMEEEETTTTEEEERRRRSSSS IIIINNNNTTTTOOOO AAAA NNNNAAAAMMMMEEEESSSSPPPPAAAACCCCEEEE::::
  433.  
  434.         $query->import_names('R');
  435.  
  436.      This creates a series of variables in the 'R' namespace.  For example,
  437.      $R::foo, @R:foo.  For keyword lists, a variable @R::keywords will appear.
  438.      If no namespace is given, this method will assume 'Q'.  WARNING:  don't
  439.      import anything into 'main'; this is a major security risk!!!!
  440.  
  441.      In older versions, this method was called iiiimmmmppppoooorrrrtttt(((()))).  As of version 2.20,
  442.      this name has been removed completely to avoid conflict with the built-in
  443.      Perl module iiiimmmmppppoooorrrrtttt operator.
  444.  
  445.      DDDDEEEELLLLEEEETTTTIIIINNNNGGGG AAAA PPPPAAAARRRRAAAAMMMMEEEETTTTEEEERRRR CCCCOOOOMMMMPPPPLLLLEEEETTTTEEEELLLLYYYY::::
  446.  
  447.          $query->delete('foo');
  448.  
  449.      This completely clears a parameter.  It sometimes useful for resetting
  450.      parameters that you don't want passed down between script invocations.
  451.  
  452.      If you are using the function call interface, use "_D_e_l_e_t_e()" instead to
  453.      avoid conflicts with Perl's built-in delete operator.
  454.  
  455.  
  456.  
  457.  
  458.  
  459.                                                                         PPPPaaaaggggeeee 7777
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  467.  
  468.  
  469.  
  470.      DDDDEEEELLLLEEEETTTTIIIINNNNGGGG AAAALLLLLLLL PPPPAAAARRRRAAAAMMMMEEEETTTTEEEERRRRSSSS::::
  471.  
  472.         $query->delete_all();
  473.  
  474.      This clears the CGI object completely.  It might be useful to ensure that
  475.      all the defaults are taken when you create a fill-out form.
  476.  
  477.      Use _D_e_l_e_t_e__a_l_l() instead if you are using the function call interface.
  478.  
  479.      DDDDIIIIRRRREEEECCCCTTTT AAAACCCCCCCCEEEESSSSSSSS TTTTOOOO TTTTHHHHEEEE PPPPAAAARRRRAAAAMMMMEEEETTTTEEEERRRR LLLLIIIISSSSTTTT::::
  480.  
  481.         $q->param_fetch('address')->[1] = '1313 Mockingbird Lane';
  482.         unshift @{$q->param_fetch(-name=>'address')},'George Munster';
  483.  
  484.      If you need access to the parameter list in a way that isn't covered by
  485.      the methods above, you can obtain a direct reference to it by calling the
  486.      ppppaaaarrrraaaammmm____ffffeeeettttcccchhhh(((()))) method with the name of the .  This will return an array
  487.      reference to the named parameters, which you then can manipulate in any
  488.      way you like.
  489.  
  490.      You can also use a named argument style using the ----nnnnaaaammmmeeee argument.
  491.  
  492.      SSSSAAAAVVVVIIIINNNNGGGG TTTTHHHHEEEE SSSSTTTTAAAATTTTEEEE OOOOFFFF TTTTHHHHEEEE SSSSCCCCRRRRIIIIPPPPTTTT TTTTOOOO AAAA FFFFIIIILLLLEEEE::::
  493.  
  494.          $query->save(FILEHANDLE)
  495.  
  496.      This will write the current state of the form to the provided filehandle.
  497.      You can read it back in by providing a filehandle to the _n_e_w() method.
  498.      Note that the filehandle can be a file, a pipe, or whatever!
  499.  
  500.      The format of the saved file is:
  501.  
  502.              NAME1=VALUE1
  503.              NAME1=VALUE1'
  504.              NAME2=VALUE2
  505.              NAME3=VALUE3
  506.              =
  507.  
  508.      Both name and value are URL escaped.  Multi-valued CGI parameters are
  509.      represented as repeated names.  A session record is delimited by a single
  510.      = symbol.  You can write out multiple records and read them back in with
  511.      several calls to nnnneeeewwww.  You can do this across several sessions by opening
  512.      the file in append mode, allowing you to create primitive guest books, or
  513.      to keep a history of users' queries.  Here's a short example of creating
  514.      multiple session records:
  515.  
  516.         use CGI;
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.                                                                         PPPPaaaaggggeeee 8888
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  533.  
  534.  
  535.  
  536.         open (OUT,">>test.out") || die;
  537.         $records = 5;
  538.         foreach (0..$records) {
  539.             my $q = new CGI;
  540.             $q->param(-name=>'counter',-value=>$_);
  541.             $q->save(OUT);
  542.         }
  543.         close OUT;
  544.  
  545.         # reopen for reading
  546.         open (IN,"test.out") || die;
  547.         while (!eof(IN)) {
  548.             my $q = new CGI(IN);
  549.             print $q->param('counter'),"\n";
  550.         }
  551.  
  552.      The file format used for save/restore is identical to that used by the
  553.      Whitehead Genome Center's data exchange format "Boulderio", and can be
  554.      manipulated and even databased using Boulderio utilities.  See
  555.        http://www.genome.wi.mit.edu/genome_software/other/boulder.html
  556.  
  557.      for further details.
  558.  
  559.      If you wish to use this method from the function-oriented (non-OO)
  560.      interface, the exported name for this method is ssssaaaavvvveeee____ppppaaaarrrraaaammmmeeeetttteeeerrrrssss(((()))).
  561.  
  562.      UUUUSSSSIIIINNNNGGGG TTTTHHHHEEEE FFFFUUUUNNNNCCCCTTTTIIIIOOOONNNN----OOOORRRRIIIIEEEENNNNTTTTEEEEDDDD IIIINNNNTTTTEEEERRRRFFFFAAAACCCCEEEE
  563.  
  564.      To use the function-oriented interface, you must specify which CGI.pm
  565.      routines or sets of routines to import into your script's namespace.
  566.      There is a small overhead associated with this importation, but it isn't
  567.      much.
  568.  
  569.         use CGI <list of methods>;
  570.  
  571.      The listed methods will be imported into the current package; you can
  572.      call them directly without creating a CGI object first.  This example
  573.      shows how to import the ppppaaaarrrraaaammmm(((()))) and hhhheeeeaaaaddddeeeerrrr(((()))) methods, and then use them
  574.      directly:
  575.  
  576.         use CGI 'param','header';
  577.         print header('text/plain');
  578.         $zipcode = param('zipcode');
  579.  
  580.      More frequently, you'll import common sets of functions by referring to
  581.      the gropus by name.  All function sets are preceded with a ":"  character
  582.      as in ":html3" (for tags defined in the HTML 3 standard).
  583.  
  584.      Here is a list of the function sets you can import:
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.                                                                         PPPPaaaaggggeeee 9999
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  599.  
  600.  
  601.  
  602.      ::::ccccggggiiii
  603.          Import all CGI-handling methods, such as ppppaaaarrrraaaammmm(((()))), ppppaaaatttthhhh____iiiinnnnffffoooo(((()))) and the
  604.          like.
  605.  
  606.      ::::ffffoooorrrrmmmm
  607.          Import all fill-out form generating methods, such as tttteeeexxxxttttffffiiiieeeelllldddd(((()))).
  608.  
  609.      ::::hhhhttttmmmmllll2222
  610.          Import all methods that generate HTML 2.0 standard elements.
  611.  
  612.      ::::hhhhttttmmmmllll3333
  613.          Import all methods that generate HTML 3.0 proposed elements (such as
  614.          <table>, <super> and <sub>).
  615.  
  616.      ::::nnnneeeettttssssccccaaaappppeeee
  617.          Import all methods that generate Netscape-specific HTML extensions.
  618.  
  619.      ::::hhhhttttmmmmllll
  620.          Import all HTML-generating shortcuts (i.e. 'html2' + 'html3' +
  621.          'netscape')...
  622.  
  623.      ::::ssssttttaaaannnnddddaaaarrrrdddd
  624.          Import "standard" features, 'html2', 'html3', 'form' and 'cgi'.
  625.  
  626.      ::::aaaallllllll
  627.          Import all the available methods.  For the full list, see the CGI.pm
  628.          code, where the variable %TAGS is defined.
  629.  
  630.      If you import a function name that is not part of CGI.pm, the module will
  631.      treat it as a new HTML tag and generate the appropriate subroutine.  You
  632.      can then use it like any other HTML tag.  This is to provide for the
  633.      rapidly-evolving HTML "standard."  For example, say Microsoft comes out
  634.      with a new tag called <GRADIENT> (which causes the user's desktop to be
  635.      flooded with a rotating gradient fill until his machine reboots).  You
  636.      don't need to wait for a new version of CGI.pm to start using it
  637.      immeidately:
  638.  
  639.         use CGI qw/:standard :html3 gradient/;
  640.         print gradient({-start=>'red',-end=>'blue'});
  641.  
  642.      Note that in the interests of execution speed CGI.pm does nnnnooootttt use the
  643.      standard the _E_x_p_o_r_t_e_r manpage syntax for specifying load symbols.  This
  644.      may change in the future.
  645.  
  646.      If you import any of the state-maintaining CGI or form-generating
  647.      methods, a default CGI object will be created and initialized
  648.      automatically the first time you use any of the methods that require one
  649.      to be present.  This includes ppppaaaarrrraaaammmm(((()))), tttteeeexxxxttttffffiiiieeeelllldddd(((()))), ssssuuuubbbbmmmmiiiitttt(((()))) and the
  650.      like.  (If you need direct access to the CGI object, you can find it in
  651.      the global variable $$$$CCCCGGGGIIII::::::::QQQQ).  By importing CGI.pm methods, you can
  652.      create visually elegant scripts:
  653.  
  654.  
  655.  
  656.  
  657.                                                                        PPPPaaaaggggeeee 11110000
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  665.  
  666.  
  667.  
  668.         use CGI qw/:standard/;
  669.         print
  670.             header,
  671.             start_html('Simple Script'),
  672.             h1('Simple Script'),
  673.             start_form,
  674.             "What's your name? ",textfield('name'),p,
  675.             "What's the combination?",
  676.             checkbox_group(-name=>'words',
  677.                            -values=>['eenie','meenie','minie','moe'],
  678.                            -defaults=>['eenie','moe']),p,
  679.             "What's your favorite color?",
  680.             popup_menu(-name=>'color',
  681.                        -values=>['red','green','blue','chartreuse']),p,
  682.             submit,
  683.             end_form,
  684.             hr,"\n";
  685.  
  686.          if (param) {
  687.             print
  688.                 "Your name is ",em(param('name')),p,
  689.                 "The keywords are: ",em(join(", ",param('words'))),p,
  690.                 "Your favorite color is ",em(param('color')),".\n";
  691.          }
  692.          print end_html;
  693.  
  694.  
  695.      PPPPRRRRAAAAGGGGMMMMAAAASSSS
  696.  
  697.      In addition to the function sets, there are a number of pragmas that you
  698.      can import.  Pragmas, which are always preceded by a hyphen, change the
  699.      way that CGI.pm functions in various ways.  Pragmas, function sets, and
  700.      individual functions can all be imported in the same _u_s_e() line.  For
  701.      example, the following use statement imports the standard set of
  702.      functions and disables debugging mode (pragma -no_debug):
  703.  
  704.         use CGI qw/:standard -no_debug/;
  705.  
  706.      The current list of pragmas is as follows:
  707.  
  708.      -any
  709.          When you _u_s_e _C_G_I -_a_n_y, then any method that the query object doesn't
  710.          recognize will be interpreted as a new HTML tag.  This allows you to
  711.          support the next _a_d _h_o_c Netscape or Microsoft HTML extension.  This
  712.          lets you go wild with new and unsupported tags:
  713.  
  714.             use CGI qw(-any);
  715.             $q=new CGI;
  716.             print $q->gradient({speed=>'fast',start=>'red',end=>'blue'});
  717.  
  718.          Since using <cite>any</cite> causes any mistyped method name to be
  719.          interpreted as an HTML tag, use it with care or not at all.
  720.  
  721.  
  722.  
  723.                                                                        PPPPaaaaggggeeee 11111111
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  731.  
  732.  
  733.  
  734.      -compile
  735.          This causes the indicated autoloaded methods to be compiled up front,
  736.          rather than deferred to later.  This is useful for scripts that run
  737.          for an extended period of time under FastCGI or mod_perl, and for
  738.          those destined to be crunched by Malcom Beattie's Perl compiler.  Use
  739.          it in conjunction with the methods or method familes you plan to use.
  740.  
  741.             use CGI qw(-compile :standard :html3);
  742.  
  743.          or even
  744.  
  745.             use CGI qw(-compile :all);
  746.  
  747.          Note that using the -compile pragma in this way will always have the
  748.          effect of importing the compiled functions into the current
  749.          namespace.  If you want to compile without importing use the
  750.          _c_o_m_p_i_l_e() method instead (see below).
  751.  
  752.      -nph
  753.          This makes CGI.pm produce a header appropriate for an NPH (no parsed
  754.          header) script.  You may need to do other things as well to tell the
  755.          server that the script is NPH.  See the discussion of NPH scripts
  756.          below.
  757.  
  758.      -autoload
  759.          This overrides the autoloader so that any function in your program
  760.          that is not recognized is referred to CGI.pm for possible evaluation.
  761.          This allows you to use all the CGI.pm functions without adding them
  762.          to your symbol table, which is of concern for mod_perl users who are
  763.          worried about memory consumption.  _W_a_r_n_i_n_g: when -_a_u_t_o_l_o_a_d is in
  764.          effect, you cannot use "poetry mode" (functions without the
  765.          parenthesis).  Use _h_r() rather than _h_r, or add something like _u_s_e
  766.          _s_u_b_s _q_w/_h_r _p _h_e_a_d_e_r/ to the top of your script.
  767.  
  768.      -no_debug
  769.          This turns off the command-line processing features.  If you want to
  770.          run a CGI.pm script from the command line to produce HTML, and you
  771.          don't want it pausing to request CGI parameters from standard input
  772.          or the command line, then use this pragma:
  773.  
  774.             use CGI qw(-no_debug :standard);
  775.  
  776.          If you'd like to process the command-line parameters but not standard
  777.          input, this should work:
  778.  
  779.             use CGI qw(-no_debug :standard);
  780.             restore_parameters(join('&',@ARGV));
  781.  
  782.          See the section on debugging for more details.
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.                                                                        PPPPaaaaggggeeee 11112222
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  797.  
  798.  
  799.  
  800.      -private_tempfiles
  801.          CGI.pm can process uploaded file. Ordinarily it spools the uploaded
  802.          file to a temporary directory, then deletes the file when done.
  803.          However, this opens the risk of eavesdropping as described in the
  804.          file upload section.  Another CGI script author could peek at this
  805.          data during the upload, even if it is confidential information. On
  806.          Unix systems, the -private_tempfiles pragma will cause the temporary
  807.          file to be unlinked as soon as it is opened and before any data is
  808.          written into it, eliminating the risk of eavesdropping.  n =back
  809.  
  810. GGGGEEEENNNNEEEERRRRAAAATTTTIIIINNNNGGGG DDDDYYYYNNNNAAAAMMMMIIIICCCC DDDDOOOOCCCCUUUUMMMMEEEENNNNTTTTSSSS
  811.      Most of CGI.pm's functions deal with creating documents on the fly.
  812.      Generally you will produce the HTTP header first, followed by the
  813.      document itself.  CGI.pm provides functions for generating HTTP headers
  814.      of various types as well as for generating HTML.  For creating GIF
  815.      images, see the GD.pm module.
  816.  
  817.      Each of these functions produces a fragment of HTML or HTTP which you can
  818.      print out directly so that it displays in the browser window, append to a
  819.      string, or save to a file for later use.
  820.  
  821.      CCCCRRRREEEEAAAATTTTIIIINNNNGGGG AAAA SSSSTTTTAAAANNNNDDDDAAAARRRRDDDD HHHHTTTTTTTTPPPP HHHHEEEEAAAADDDDEEEERRRR::::
  822.  
  823.      Normally the first thing you will do in any CGI script is print out an
  824.      HTTP header.  This tells the browser what type of document to expect, and
  825.      gives other optional information, such as the language, expiration date,
  826.      and whether to cache the document.  The header can also be manipulated
  827.      for special purposes, such as server push and pay per view pages.
  828.  
  829.              print $query->header;
  830.  
  831.                   -or-
  832.  
  833.              print $query->header('image/gif');
  834.  
  835.                   -or-
  836.  
  837.              print $query->header('text/html','204 No response');
  838.  
  839.                   -or-
  840.  
  841.              print $query->header(-type=>'image/gif',
  842.                                   -nph=>1,
  843.                                   -status=>'402 Payment required',
  844.                                   -expires=>'+3d',
  845.                                   -cookie=>$cookie,
  846.                                   -Cost=>'$2.00');
  847.  
  848.      _h_e_a_d_e_r() returns the Content-type: header.  You can provide your own MIME
  849.      type if you choose, otherwise it defaults to text/html.  An optional
  850.      second parameter specifies the status code and a human-readable message.
  851.      For example, you can specify 204, "No response" to create a script that
  852.  
  853.  
  854.  
  855.                                                                        PPPPaaaaggggeeee 11113333
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  863.  
  864.  
  865.  
  866.      tells the browser to do nothing at all.
  867.  
  868.      The last example shows the named argument style for passing arguments to
  869.      the CGI methods using named parameters.  Recognized parameters are ----ttttyyyyppppeeee,
  870.      ----ssssttttaaaattttuuuussss, ----eeeexxxxppppiiiirrrreeeessss, and ----ccccooooooookkkkiiiieeee.  Any other named parameters will be
  871.      stripped of their initial hyphens and turned into header fields, allowing
  872.      you to specify any HTTP header you desire.  Internal underscores will be
  873.      turned into hyphens:
  874.  
  875.          print $query->header(-Content_length=>3002);
  876.  
  877.      Most browsers will not cache the output from CGI scripts.  Every time the
  878.      browser reloads the page, the script is invoked anew.  You can change
  879.      this behavior with the ----eeeexxxxppppiiiirrrreeeessss parameter.  When you specify an absolute
  880.      or relative expiration interval with this parameter, some browsers and
  881.      proxy servers will cache the script's output until the indicated
  882.      expiration date.  The following forms are all valid for the -expires
  883.      field:
  884.  
  885.              +30s                              30 seconds from now
  886.              +10m                              ten minutes from now
  887.              +1h                               one hour from now
  888.              -1d                               yesterday (i.e. "ASAP!")
  889.              now                               immediately
  890.              +3M                               in three months
  891.              +10y                              in ten years time
  892.              Thursday, 25-Apr-1999 00:40:33 GMT  at the indicated time & date
  893.  
  894.      The ----ccccooooooookkkkiiiieeee parameter generates a header that tells the browser to
  895.      provide a "magic cookie" during all subsequent transactions with your
  896.      script.  Netscape cookies have a special format that includes interesting
  897.      attributes such as expiration time.  Use the _c_o_o_k_i_e() method to create
  898.      and retrieve session cookies.
  899.  
  900.      The ----nnnnpppphhhh parameter, if set to a true value, will issue the correct
  901.      headers to work with a NPH (no-parse-header) script.  This is important
  902.      to use with certain servers, such as Microsoft Internet Explorer, which
  903.      expect all their scripts to be NPH.
  904.  
  905.      GGGGEEEENNNNEEEERRRRAAAATTTTIIIINNNNGGGG AAAA RRRREEEEDDDDIIIIRRRREEEECCCCTTTTIIIIOOOONNNN HHHHEEEEAAAADDDDEEEERRRR
  906.  
  907.         print $query->redirect('http://somewhere.else/in/movie/land');
  908.  
  909.      Sometimes you don't want to produce a document yourself, but simply
  910.      redirect the browser elsewhere, perhaps choosing a URL based on the time
  911.      of day or the identity of the user.
  912.  
  913.      The _r_e_d_i_r_e_c_t() function redirects the browser to a different URL.  If you
  914.      use redirection like this, you should nnnnooootttt print out a header as well.  As
  915.      of version 2.0, we produce both the unofficial Location:  header and the
  916.      official URI: header.  This should satisfy most servers and browsers.
  917.  
  918.  
  919.  
  920.  
  921.                                                                        PPPPaaaaggggeeee 11114444
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  929.  
  930.  
  931.  
  932.      One hint I can offer is that relative links may not work correctly when
  933.      you generate a redirection to another document on your site.  This is due
  934.      to a well-intentioned optimization that some servers use.  The solution
  935.      to this is to use the full URL (including the http: part) of the document
  936.      you are redirecting to.
  937.  
  938.      You can also use named arguments:
  939.  
  940.          print $query->redirect(-uri=>'http://somewhere.else/in/movie/land',
  941.                                 -nph=>1);
  942.  
  943.      The ----nnnnpppphhhh parameter, if set to a true value, will issue the correct
  944.      headers to work with a NPH (no-parse-header) script.  This is important
  945.      to use with certain servers, such as Microsoft Internet Explorer, which
  946.      expect all their scripts to be NPH.
  947.  
  948.      CCCCRRRREEEEAAAATTTTIIIINNNNGGGG TTTTHHHHEEEE HHHHTTTTMMMMLLLL DDDDOOOOCCCCUUUUMMMMEEEENNNNTTTT HHHHEEEEAAAADDDDEEEERRRR
  949.  
  950.         print $query->start_html(-title=>'Secrets of the Pyramids',
  951.                                  -author=>'fred@capricorn.org',
  952.                                  -base=>'true',
  953.                                  -target=>'_blank',
  954.                                  -meta=>{'keywords'=>'pharaoh secret mummy',
  955.                                          'copyright'=>'copyright 1996 King Tut'},
  956.                                  -style=>{'src'=>'/styles/style1.css'},
  957.                                  -BGCOLOR=>'blue');
  958.  
  959.      After creating the HTTP header, most CGI scripts will start writing out
  960.      an HTML document.  The _s_t_a_r_t__h_t_m_l() routine creates the top of the page,
  961.      along with a lot of optional information that controls the page's
  962.      appearance and behavior.
  963.  
  964.      This method returns a canned HTML header and the opening <BODY> tag.  All
  965.      parameters are optional.  In the named parameter form, recognized
  966.      parameters are -title, -author, -base, -xbase and -target (see below for
  967.      the explanation).  Any additional parameters you provide, such as the
  968.      Netscape unofficial BGCOLOR attribute, are added to the <BODY> tag.
  969.      Additional parameters must be proceeded by a hyphen.
  970.  
  971.      The argument ----xxxxbbbbaaaasssseeee allows you to provide an HREF for the <BASE> tag
  972.      different from the current location, as in
  973.  
  974.          -xbase=>"http://home.mcom.com/"
  975.  
  976.      All relative links will be interpreted relative to this tag.
  977.  
  978.      The argument ----ttttaaaarrrrggggeeeetttt allows you to provide a default target frame for all
  979.      the links and fill-out forms on the page.  See the Netscape documentation
  980.      on frames for details of how to manipulate this.
  981.  
  982.          -target=>"answer_window"
  983.  
  984.  
  985.  
  986.  
  987.                                                                        PPPPaaaaggggeeee 11115555
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  995.  
  996.  
  997.  
  998.      All relative links will be interpreted relative to this tag.  You add
  999.      arbitrary meta information to the header with the ----mmmmeeeettttaaaa argument.  This
  1000.      argument expects a reference to an associative array containing
  1001.      name/value pairs of meta information.  These will be turned into a series
  1002.      of header <META> tags that look something like this:
  1003.  
  1004.          <META NAME="keywords" CONTENT="pharaoh secret mummy">
  1005.          <META NAME="description" CONTENT="copyright 1996 King Tut">
  1006.  
  1007.      There is no support for the HTTP-EQUIV type of <META> tag.  This is
  1008.      because you can modify the HTTP header directly with the hhhheeeeaaaaddddeeeerrrr(((()))) method.
  1009.      For example, if you want to send the Refresh: header, do it in the
  1010.      _h_e_a_d_e_r() method:
  1011.  
  1012.          print $q->header(-Refresh=>'10; URL=http://www.capricorn.com');
  1013.  
  1014.      The ----ssssttttyyyylllleeee tag is used to incorporate cascading stylesheets into your
  1015.      code.  See the section on CASCADING STYLESHEETS for more information.
  1016.  
  1017.      You can place other arbitrary HTML elements to the <HEAD> section with
  1018.      the ----hhhheeeeaaaadddd tag.  For example, to place the rarely-used <LINK> element in
  1019.      the head section, use this:
  1020.  
  1021.          print $q->start_html(-head=>Link({-rel=>'next',
  1022.                                        -href=>'http://www.capricorn.com/s2.html'}));
  1023.  
  1024.      To incorporate multiple HTML elements into the <HEAD> section, just pass
  1025.      an array reference:
  1026.  
  1027.          print $q->start_html(-head=>[
  1028.                                    Link({-rel=>'next',
  1029.                                          -href=>'http://www.capricorn.com/s2.html'}),
  1030.                                    Link({-rel=>'previous',
  1031.                                          -href=>'http://www.capricorn.com/s1.html'})
  1032.                                   ]
  1033.                           );
  1034.  
  1035.      JAVASCRIPTING: The ----ssssccccrrrriiiipppptttt, ----nnnnooooSSSSccccrrrriiiipppptttt, ----oooonnnnLLLLooooaaaadddd, ----oooonnnnMMMMoooouuuusssseeeeOOOOvvvveeeerrrr, ----oooonnnnMMMMoooouuuusssseeeeOOOOuuuutttt
  1036.      and ----oooonnnnUUUUnnnnllllooooaaaadddd parameters are used to add Netscape JavaScript calls to
  1037.      your pages.  ----ssssccccrrrriiiipppptttt should point to a block of text containing
  1038.      JavaScript function definitions.  This block will be placed within a
  1039.      <SCRIPT> block inside the HTML (not HTTP) header.  The block is placed in
  1040.      the header in order to give your page a fighting chance of having all its
  1041.      JavaScript functions in place even if the user presses the stop button
  1042.      before the page has loaded completely.  CGI.pm attempts to format the
  1043.      script in such a way that JavaScript-naive browsers will not choke on the
  1044.      code: unfortunately there are some browsers, such as Chimera for Unix,
  1045.      that get confused by it nevertheless.
  1046.  
  1047.      The ----oooonnnnLLLLooooaaaadddd and ----oooonnnnUUUUnnnnllllooooaaaadddd parameters point to fragments of JavaScript
  1048.      code to execute when the page is respectively opened and closed by the
  1049.      browser.  Usually these parameters are calls to functions defined in the
  1050.  
  1051.  
  1052.  
  1053.                                                                        PPPPaaaaggggeeee 11116666
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  1061.  
  1062.  
  1063.  
  1064.      ----ssssccccrrrriiiipppptttt field:
  1065.  
  1066.            $query = new CGI;
  1067.            print $query->header;
  1068.            $JSCRIPT=<<END;
  1069.            // Ask a silly question
  1070.            function riddle_me_this() {
  1071.               var r = prompt("What walks on four legs in the morning, " +
  1072.                             "two legs in the afternoon, " +
  1073.                             "and three legs in the evening?");
  1074.               response(r);
  1075.            }
  1076.            // Get a silly answer
  1077.            function response(answer) {
  1078.               if (answer == "man")
  1079.                  alert("Right you are!");
  1080.               else
  1081.                  alert("Wrong!  Guess again.");
  1082.            }
  1083.            END
  1084.            print $query->start_html(-title=>'The Riddle of the Sphinx',
  1085.                                     -script=>$JSCRIPT);
  1086.  
  1087.      Use the ----nnnnooooSSSSccccrrrriiiipppptttt parameter to pass some HTML text that will be displayed
  1088.      on browsers that do not have JavaScript (or browsers where JavaScript is
  1089.      turned off).
  1090.  
  1091.      Netscape 3.0 recognizes several attributes of the <SCRIPT> tag, including
  1092.      LANGUAGE and SRC.  The latter is particularly interesting, as it allows
  1093.      you to keep the JavaScript code in a file or CGI script rather than
  1094.      cluttering up each page with the source.  To use these attributes pass a
  1095.      HASH reference in the ----ssssccccrrrriiiipppptttt parameter containing one or more of
  1096.      -language, -src, or -code:
  1097.  
  1098.          print $q->start_html(-title=>'The Riddle of the Sphinx',
  1099.                               -script=>{-language=>'JAVASCRIPT',
  1100.                                         -src=>'/javascript/sphinx.js'}
  1101.                               );
  1102.  
  1103.          print $q->(-title=>'The Riddle of the Sphinx',
  1104.                     -script=>{-language=>'PERLSCRIPT'},
  1105.                               -code=>'print "hello world!\n;"'
  1106.                     );
  1107.  
  1108.      A final feature allows you to incorporate multiple <SCRIPT> sections into
  1109.      the header.  Just pass the list of script sections as an array reference.
  1110.      this allows you to specify different source files for different dialects
  1111.      of JavaScript.  Example:
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.                                                                        PPPPaaaaggggeeee 11117777
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  1127.  
  1128.  
  1129.  
  1130.           print $q->start_html(-title=>'The Riddle of the Sphinx',
  1131.                                -script=>[
  1132.                                          { -language => 'JavaScript1.0',
  1133.                                            -src      => '/javascript/utilities10.js'
  1134.                                          },
  1135.                                          { -language => 'JavaScript1.1',
  1136.                                            -src      => '/javascript/utilities11.js'
  1137.                                          },
  1138.                                          { -language => 'JavaScript1.2',
  1139.                                            -src      => '/javascript/utilities12.js'
  1140.                                          },
  1141.                                          { -language => 'JavaScript28.2',
  1142.                                            -src      => '/javascript/utilities219.js'
  1143.                                          }
  1144.                                       ]
  1145.                                   );
  1146.           </pre>
  1147.  
  1148.      If this looks a bit extreme, take my advice and stick with straight CGI
  1149.      scripting.
  1150.  
  1151.      See
  1152.  
  1153.         http://home.netscape.com/eng/mozilla/2.0/handbook/javascript/
  1154.  
  1155.      for more information about JavaScript.
  1156.  
  1157.      The old-style positional parameters are as follows:
  1158.  
  1159.      PPPPaaaarrrraaaammmmeeeetttteeeerrrrssss::::
  1160.  
  1161.      1.      The title
  1162.  
  1163.      2.      The author's e-mail address (will create a <LINK REV="MADE"> tag
  1164.              if present
  1165.  
  1166.      3.      A 'true' flag if you want to include a <BASE> tag in the header.
  1167.              This helps resolve relative addresses to absolute ones when the
  1168.              document is moved, but makes the document hierarchy non-portable.
  1169.              Use with care!
  1170.  
  1171.      4, 5, 6...
  1172.              Any other parameters you want to include in the <BODY> tag.  This
  1173.              is a good place to put Netscape extensions, such as colors and
  1174.              wallpaper patterns.
  1175.  
  1176.      EEEENNNNDDDDIIIINNNNGGGG TTTTHHHHEEEE HHHHTTTTMMMMLLLL DDDDOOOOCCCCUUUUMMMMEEEENNNNTTTT::::
  1177.  
  1178.              print $query->end_html
  1179.  
  1180.      This ends an HTML document by printing the </BODY></HTML> tags.
  1181.  
  1182.  
  1183.  
  1184.  
  1185.                                                                        PPPPaaaaggggeeee 11118888
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  1193.  
  1194.  
  1195.  
  1196.      CCCCRRRREEEEAAAATTTTIIIINNNNGGGG AAAA SSSSEEEELLLLFFFF----RRRREEEEFFFFEEEERRRREEEENNNNCCCCIIIINNNNGGGG UUUURRRRLLLL TTTTHHHHAAAATTTT PPPPRRRREEEESSSSEEEERRRRVVVVEEEESSSS SSSSTTTTAAAATTTTEEEE IIIINNNNFFFFOOOORRRRMMMMAAAATTTTIIIIOOOONNNN::::
  1197.  
  1198.          $myself = $query->self_url;
  1199.          print "<A HREF=$myself>I'm talking to myself.</A>";
  1200.  
  1201.      _s_e_l_f__u_r_l() will return a URL, that, when selected, will reinvoke this
  1202.      script with all its state information intact.  This is most useful when
  1203.      you want to jump around within the document using internal anchors but
  1204.      you don't want to disrupt the current contents of the _f_o_r_m(s).  Something
  1205.      like this will do the trick.
  1206.  
  1207.           $myself = $query->self_url;
  1208.           print "<A HREF=$myself#table1>See table 1</A>";
  1209.           print "<A HREF=$myself#table2>See table 2</A>";
  1210.           print "<A HREF=$myself#yourself>See for yourself</A>";
  1211.  
  1212.      If you want more control over what's returned, using the uuuurrrrllll(((()))) method
  1213.      instead.
  1214.  
  1215.      You can also retrieve the unprocessed query string with _q_u_e_r_y__s_t_r_i_n_g():
  1216.  
  1217.          $the_string = $query->query_string;
  1218.  
  1219.  
  1220.      OOOOBBBBTTTTAAAAIIIINNNNIIIINNNNGGGG TTTTHHHHEEEE SSSSCCCCRRRRIIIIPPPPTTTT''''SSSS UUUURRRRLLLL
  1221.  
  1222.          $full_url      = $query->url();
  1223.          $full_url      = $query->url(-full=>1);  #alternative syntax
  1224.          $relative_url  = $query->url(-relative=>1);
  1225.          $absolute_url  = $query->url(-absolute=>1);
  1226.          $url_with_path = $query->url(-path_info=>1);
  1227.          $url_with_path_and_query = $query->url(-path_info=>1,-query=>1);
  1228.  
  1229.      uuuurrrrllll(((()))) returns the script's URL in a variety of formats.  Called without
  1230.      any arguments, it returns the full form of the URL, including host name
  1231.      and port number
  1232.  
  1233.          http://your.host.com/path/to/script.cgi
  1234.  
  1235.      You can modify this format with the following named arguments:
  1236.  
  1237.      ----aaaabbbbssssoooolllluuuutttteeee
  1238.              If true, produce an absolute URL, e.g.
  1239.  
  1240.                  /path/to/script.cgi
  1241.  
  1242.  
  1243.      ----rrrreeeellllaaaattttiiiivvvveeee
  1244.              Produce a relative URL.  This is useful if you want to reinvoke
  1245.              your script with different parameters. For example:
  1246.  
  1247.                  script.cgi
  1248.  
  1249.  
  1250.  
  1251.                                                                        PPPPaaaaggggeeee 11119999
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  1259.  
  1260.  
  1261.  
  1262.      ----ffffuuuullllllll   Produce the full URL, exactly as if called without any arguments.
  1263.              This overrides the -relative and -absolute arguments.
  1264.  
  1265.      ----ppppaaaatttthhhh (----ppppaaaatttthhhh____iiiinnnnffffoooo)
  1266.              Append the additional path information to the URL.  This can be
  1267.              combined with ----ffffuuuullllllll, ----aaaabbbbssssoooolllluuuutttteeee or ----rrrreeeellllaaaattttiiiivvvveeee.  ----ppppaaaatttthhhh____iiiinnnnffffoooo is
  1268.              provided as a synonym.
  1269.  
  1270.      ----qqqquuuueeeerrrryyyy (----qqqquuuueeeerrrryyyy____ssssttttrrrriiiinnnngggg)
  1271.              Append the query string to the URL.  This can be combined with
  1272.              ----ffffuuuullllllll, ----aaaabbbbssssoooolllluuuutttteeee or ----rrrreeeellllaaaattttiiiivvvveeee.  ----qqqquuuueeeerrrryyyy____ssssttttrrrriiiinnnngggg is provided as a
  1273.              synonym.
  1274.  
  1275. CCCCRRRREEEEAAAATTTTIIIINNNNGGGG SSSSTTTTAAAANNNNDDDDAAAARRRRDDDD HHHHTTTTMMMMLLLL EEEELLLLEEEEMMMMEEEENNNNTTTTSSSS::::
  1276.      CGI.pm defines general HTML shortcut methods for most, if not all of the
  1277.      HTML 3 and HTML 4 tags.  HTML shortcuts are named after a single HTML
  1278.      element and return a fragment of HTML text that you can then print or
  1279.      manipulate as you like.  Each shortcut returns a fragment of HTML code
  1280.      that you can append to a string, save to a file, or, most commonly, print
  1281.      out so that it displays in the browser window.
  1282.  
  1283.      This example shows how to use the HTML methods:
  1284.  
  1285.         $q = new CGI;
  1286.         print $q->blockquote(
  1287.                           "Many years ago on the island of",
  1288.                           $q->a({href=>"http://crete.org/"},"Crete"),
  1289.                           "there lived a minotaur named",
  1290.                           $q->strong("Fred."),
  1291.                          ),
  1292.             $q->hr;
  1293.  
  1294.      This results in the following HTML code (extra newlines have been added
  1295.      for readability):
  1296.  
  1297.         <blockquote>
  1298.         Many years ago on the island of
  1299.         <a HREF="http://crete.org/">Crete</a> there lived
  1300.         a minotaur named <strong>Fred.</strong>
  1301.         </blockquote>
  1302.         <hr>
  1303.  
  1304.      If you find the syntax for calling the HTML shortcuts awkward, you can
  1305.      import them into your namespace and dispense with the object syntax
  1306.      completely (see the next section for more details):
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.                                                                        PPPPaaaaggggeeee 22220000
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  1325.  
  1326.  
  1327.  
  1328.         use CGI ':standard';
  1329.         print blockquote(
  1330.            "Many years ago on the island of",
  1331.            a({href=>"http://crete.org/"},"Crete"),
  1332.            "there lived a minotaur named",
  1333.            strong("Fred."),
  1334.            ),
  1335.            hr;
  1336.  
  1337.  
  1338.      PPPPRRRROOOOVVVVIIIIDDDDIIIINNNNGGGG AAAARRRRGGGGUUUUMMMMEEEENNNNTTTTSSSS TTTTOOOO HHHHTTTTMMMMLLLL SSSSHHHHOOOORRRRTTTTCCCCUUUUTTTTSSSS
  1339.  
  1340.      The HTML methods will accept zero, one or multiple arguments.  If you
  1341.      provide no arguments, you get a single tag:
  1342.  
  1343.         print hr;    #  <HR>
  1344.  
  1345.      If you provide one or more string arguments, they are concatenated
  1346.      together with spaces and placed between opening and closing tags:
  1347.  
  1348.         print h1("Chapter","1"); # <H1>Chapter 1</H1>"
  1349.  
  1350.      If the first argument is an associative array reference, then the keys
  1351.      and values of the associative array become the HTML tag's attributes:
  1352.  
  1353.         print a({-href=>'fred.html',-target=>'_new'},
  1354.            "Open a new frame");
  1355.  
  1356.                  <A HREF="fred.html",TARGET="_new">Open a new frame</A>
  1357.  
  1358.      You may dispense with the dashes in front of the attribute names if
  1359.      you prefer:
  1360.  
  1361.         print img {src=>'fred.gif',align=>'LEFT'};
  1362.  
  1363.                 <IMG ALIGN="LEFT" SRC="fred.gif">
  1364.  
  1365.      Sometimes an HTML tag attribute has no argument.  For example, ordered
  1366.      lists can be marked as COMPACT.  The syntax for this is an argument that
  1367.      that points to an undef string:
  1368.  
  1369.         print ol({compact=>undef},li('one'),li('two'),li('three'));
  1370.  
  1371.      Prior to CGI.pm version 2.41, providing an empty ('') string as an
  1372.      attribute argument was the same as providing undef.  However, this has
  1373.      changed in order to accomodate those who want to create tags of the form
  1374.      <IMG ALT="">.  The difference is shown in these two pieces of code:
  1375.  
  1376.         CODE                   RESULT
  1377.         _i_m_g({alt=>undef})      <IMG ALT>
  1378.         _i_m_g({alt=>''})         <IMT ALT="">
  1379.  
  1380.  
  1381.  
  1382.  
  1383.                                                                        PPPPaaaaggggeeee 22221111
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  1391.  
  1392.  
  1393.  
  1394.      TTTTHHHHEEEE DDDDIIIISSSSTTTTRRRRIIIIBBBBUUUUTTTTIIIIVVVVEEEE PPPPRRRROOOOPPPPEEEERRRRTTTTYYYY OOOOFFFF HHHHTTTTMMMMLLLL SSSSHHHHOOOORRRRTTTTCCCCUUUUTTTTSSSS
  1395.  
  1396.      One of the cool features of the HTML shortcuts is that they are
  1397.      distributive.  If you give them an argument consisting of a rrrreeeeffffeeeerrrreeeennnncccceeee to
  1398.      a list, the tag will be distributed across each element of the list.  For
  1399.      example, here's one way to make an ordered list:
  1400.  
  1401.         print ul(
  1402.                   li({-type=>'disc'},['Sneezy','Doc','Sleepy','Happy']);
  1403.                 );
  1404.  
  1405.      This example will result in HTML output that looks like this:
  1406.  
  1407.         <UL>
  1408.           <LI TYPE="disc">Sneezy</LI>
  1409.           <LI TYPE="disc">Doc</LI>
  1410.           <LI TYPE="disc">Sleepy</LI>
  1411.           <LI TYPE="disc">Happy</LI>
  1412.         </UL>
  1413.  
  1414.      This is extremely useful for creating tables.  For example:
  1415.  
  1416.         print table({-border=>undef},
  1417.                 caption('When Should You Eat Your Vegetables?'),
  1418.                 Tr({-align=>CENTER,-valign=>TOP},
  1419.                 [
  1420.                    th(['Vegetable', 'Breakfast','Lunch','Dinner']),
  1421.                    td(['Tomatoes' , 'no', 'yes', 'yes']),
  1422.                    td(['Broccoli' , 'no', 'no',  'yes']),
  1423.                    td(['Onions'   , 'yes','yes', 'yes'])
  1424.                 ]
  1425.                 )
  1426.              );
  1427.  
  1428.  
  1429.      HHHHTTTTMMMMLLLL SSSSHHHHOOOORRRRTTTTCCCCUUUUTTTTSSSS AAAANNNNDDDD LLLLIIIISSSSTTTT IIIINNNNTTTTEEEERRRRPPPPOOOOLLLLAAAATTTTIIIIOOOONNNN
  1430.  
  1431.      Consider this bit of code:
  1432.  
  1433.         print blockquote(em('Hi'),'mom!'));
  1434.  
  1435.      It will ordinarily return the string that you probably expect, namely:
  1436.  
  1437.         <BLOCKQUOTE><EM>Hi</EM> mom!</BLOCKQUOTE>
  1438.  
  1439.      Note the space between the element "Hi" and the element "mom!".  CGI.pm
  1440.      puts the extra space there using array interpolation, which is controlled
  1441.      by the magic $" variable.  Sometimes this extra space is not what you
  1442.      want, for example, when you are trying to align a series of images.  In
  1443.      this case, you can simply change the value of $" to an empty string.
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.                                                                        PPPPaaaaggggeeee 22222222
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  1457.  
  1458.  
  1459.  
  1460.         {
  1461.            local($") = '';
  1462.            print blockquote(em('Hi'),'mom!'));
  1463.          }
  1464.  
  1465.      I suggest you put the code in a block as shown here.  Otherwise the
  1466.      change to $" will affect all subsequent code until you explicitly reset
  1467.      it.
  1468.  
  1469.      NNNNOOOONNNN----SSSSTTTTAAAANNNNDDDDAAAARRRRDDDD HHHHTTTTMMMMLLLL SSSSHHHHOOOORRRRTTTTCCCCUUUUTTTTSSSS
  1470.  
  1471.      A few HTML tags don't follow the standard pattern for various reasons.
  1472.  
  1473.      ccccoooommmmmmmmeeeennnntttt(((()))) generates an HTML comment (<!-- comment -->).  Call it like
  1474.  
  1475.          print comment('here is my comment');
  1476.  
  1477.      Because of conflicts with built-in Perl functions, the following
  1478.      functions begin with initial caps:
  1479.  
  1480.          Select
  1481.          Tr
  1482.          Link
  1483.          Delete
  1484.  
  1485.      In addition, _s_t_a_r_t__h_t_m_l(), _e_n_d__h_t_m_l(), _s_t_a_r_t__f_o_r_m(), _e_n_d__f_o_r_m(),
  1486.      _s_t_a_r_t__m_u_l_t_i_p_a_r_t__f_o_r_m() and all the fill-out form tags are special.  See
  1487.      their respective sections.
  1488.  
  1489. CCCCRRRREEEEAAAATTTTIIIINNNNGGGG FFFFIIIILLLLLLLL----OOOOUUUUTTTT FFFFOOOORRRRMMMMSSSS::::
  1490.      _G_e_n_e_r_a_l _n_o_t_e  The various form-creating methods all return strings to the
  1491.      caller, containing the tag or tags that will create the requested form
  1492.      element.  You are responsible for actually printing out these strings.
  1493.      It's set up this way so that you can place formatting tags around the
  1494.      form elements.
  1495.  
  1496.      _A_n_o_t_h_e_r _n_o_t_e The default values that you specify for the forms are only
  1497.      used the ffffiiiirrrrsssstttt time the script is invoked (when there is no query
  1498.      string).  On subsequent invocations of the script (when there is a query
  1499.      string), the former values are used even if they are blank.
  1500.  
  1501.      If you want to change the value of a field from its previous value, you
  1502.      have two choices:
  1503.  
  1504.      (1) call the _p_a_r_a_m() method to set it.
  1505.  
  1506.      (2) use the -override (alias -force) parameter (a new feature in version
  1507.      2.15).  This forces the default value to be used, regardless of the
  1508.      previous value:
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.                                                                        PPPPaaaaggggeeee 22223333
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  1523.  
  1524.  
  1525.  
  1526.         print $query->textfield(-name=>'field_name',
  1527.                                 -default=>'starting value',
  1528.                                 -override=>1,
  1529.                                 -size=>50,
  1530.                                 -maxlength=>80);
  1531.  
  1532.      _Y_e_t _a_n_o_t_h_e_r _n_o_t_e By default, the text and labels of form elements are
  1533.      escaped according to HTML rules.  This means that you can safely use
  1534.      "<CLICK ME>" as the label for a button.  However, it also interferes with
  1535.      your ability to incorporate special HTML character sequences, such as
  1536.      Á, into your fields.  If you wish to turn off automatic escaping,
  1537.      call the _a_u_t_o_E_s_c_a_p_e() method with a false value immediately after
  1538.      creating the CGI object:
  1539.  
  1540.         $query = new CGI;
  1541.         $query->autoEscape(undef);
  1542.  
  1543.  
  1544.  
  1545.      CCCCRRRREEEEAAAATTTTIIIINNNNGGGG AAAANNNN IIIISSSSIIIINNNNDDDDEEEEXXXX TTTTAAAAGGGG
  1546.  
  1547.         print $query->isindex(-action=>$action);
  1548.  
  1549.               -or-
  1550.  
  1551.         print $query->isindex($action);
  1552.  
  1553.      Prints out an <ISINDEX> tag.  Not very exciting.  The parameter -action
  1554.      specifies the URL of the script to process the query.  The default is to
  1555.      process the query with the current script.
  1556.  
  1557.      SSSSTTTTAAAARRRRTTTTIIIINNNNGGGG AAAANNNNDDDD EEEENNNNDDDDIIIINNNNGGGG AAAA FFFFOOOORRRRMMMM
  1558.  
  1559.          print $query->startform(-method=>$method,
  1560.                                  -action=>$action,
  1561.                                  -encoding=>$encoding);
  1562.            <... various form stuff ...>
  1563.          print $query->endform;
  1564.  
  1565.              -or-
  1566.  
  1567.          print $query->startform($method,$action,$encoding);
  1568.            <... various form stuff ...>
  1569.          print $query->endform;
  1570.  
  1571.      _s_t_a_r_t_f_o_r_m() will return a <FORM> tag with the optional method, action and
  1572.      form encoding that you specify.  The defaults are:
  1573.          method: POST
  1574.          action: this script
  1575.          encoding: application/x-www-form-urlencoded
  1576.  
  1577.      _e_n_d_f_o_r_m() returns the closing </FORM> tag.
  1578.  
  1579.  
  1580.  
  1581.                                                                        PPPPaaaaggggeeee 22224444
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  1589.  
  1590.  
  1591.  
  1592.      _S_t_a_r_t_f_o_r_m()'s encoding method tells the browser how to package the
  1593.      various fields of the form before sending the form to the server.  Two
  1594.      values are possible:
  1595.  
  1596.      aaaapppppppplllliiiiccccaaaattttiiiioooonnnn////xxxx----wwwwwwwwwwww----ffffoooorrrrmmmm----uuuurrrrlllleeeennnnccccooooddddeeeedddd
  1597.              This is the older type of encoding used by all browsers prior to
  1598.              Netscape 2.0.  It is compatible with many CGI scripts and is
  1599.              suitable for short fields containing text data.  For your
  1600.              convenience, CGI.pm stores the name of this encoding type in
  1601.              $$$$CCCCGGGGIIII::::::::UUUURRRRLLLL____EEEENNNNCCCCOOOODDDDEEEEDDDD.
  1602.  
  1603.      mmmmuuuullllttttiiiippppaaaarrrrtttt////ffffoooorrrrmmmm----ddddaaaattttaaaa
  1604.              This is the newer type of encoding introduced by Netscape 2.0.
  1605.              It is suitable for forms that contain very large fields or that
  1606.              are intended for transferring binary data.  Most importantly, it
  1607.              enables the "file upload" feature of Netscape 2.0 forms.  For
  1608.              your convenience, CGI.pm stores the name of this encoding type in
  1609.              &&&&CCCCGGGGIIII::::::::MMMMUUUULLLLTTTTIIIIPPPPAAAARRRRTTTT
  1610.  
  1611.              Forms that use this type of encoding are not easily interpreted
  1612.              by CGI scripts unless they use CGI.pm or another library designed
  1613.              to handle them.
  1614.  
  1615.              For compatibility, the _s_t_a_r_t_f_o_r_m() method uses the older form of
  1616.              encoding by default.  If you want to use the newer form of
  1617.              encoding by default, you can call ssssttttaaaarrrrtttt____mmmmuuuullllttttiiiippppaaaarrrrtttt____ffffoooorrrrmmmm(((()))) instead
  1618.              of ssssttttaaaarrrrttttffffoooorrrrmmmm(((()))).
  1619.  
  1620.              JAVASCRIPTING: The ----nnnnaaaammmmeeee and ----oooonnnnSSSSuuuubbbbmmmmiiiitttt parameters are provided
  1621.              for use with JavaScript.  The -name parameter gives the form a
  1622.              name so that it can be identified and manipulated by JavaScript
  1623.              functions.  -onSubmit should point to a JavaScript function that
  1624.              will be executed just before the form is submitted to your
  1625.              server.  You can use this opportunity to check the contents of
  1626.              the form for consistency and completeness.  If you find something
  1627.              wrong, you can put up an alert box or maybe fix things up
  1628.              yourself.  You can abort the submission by returning false from
  1629.              this function.
  1630.  
  1631.              Usually the bulk of JavaScript functions are defined in a
  1632.              <SCRIPT> block in the HTML header and -onSubmit points to one of
  1633.              these function call.  See _s_t_a_r_t__h_t_m_l() for details.
  1634.  
  1635.      CCCCRRRREEEEAAAATTTTIIIINNNNGGGG AAAA TTTTEEEEXXXXTTTT FFFFIIIIEEEELLLLDDDD
  1636.  
  1637.          print $query->textfield(-name=>'field_name',
  1638.                                  -default=>'starting value',
  1639.                                  -size=>50,
  1640.                                  -maxlength=>80);
  1641.              -or-
  1642.  
  1643.          print $query->textfield('field_name','starting value',50,80);
  1644.  
  1645.  
  1646.  
  1647.                                                                        PPPPaaaaggggeeee 22225555
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  1655.  
  1656.  
  1657.  
  1658.      _t_e_x_t_f_i_e_l_d() will return a text input field.
  1659.  
  1660.      PPPPaaaarrrraaaammmmeeeetttteeeerrrrssss
  1661.  
  1662.      1.      The first parameter is the required name for the field (-name).
  1663.  
  1664.      2.      The optional second parameter is the default starting value for
  1665.              the field contents (-default).
  1666.  
  1667.      3.      The optional third parameter is the size of the field in
  1668.                    characters (-size).
  1669.  
  1670.      4.      The optional fourth parameter is the maximum number of characters
  1671.              the
  1672.                    field will accept (-maxlength).
  1673.  
  1674.              As with all these methods, the field will be initialized with its
  1675.              previous contents from earlier invocations of the script.  When
  1676.              the form is processed, the value of the text field can be
  1677.              retrieved with:
  1678.  
  1679.                     $value = $query->param('foo');
  1680.  
  1681.              If you want to reset it from its initial value after the script
  1682.              has been called once, you can do so like this:
  1683.  
  1684.                     $query->param('foo',"I'm taking over this value!");
  1685.  
  1686.              NEW AS OF VERSION 2.15: If you don't want the field to take on
  1687.              its previous value, you can force its current value by using the
  1688.              -override (alias -force) parameter:
  1689.  
  1690.                  print $query->textfield(-name=>'field_name',
  1691.                                          -default=>'starting value',
  1692.                                          -override=>1,
  1693.                                          -size=>50,
  1694.                                          -maxlength=>80);
  1695.  
  1696.              JAVASCRIPTING: You can also provide ----oooonnnnCCCChhhhaaaannnnggggeeee, ----oooonnnnFFFFooooccccuuuussss, ----oooonnnnBBBBlllluuuurrrr,
  1697.              ----oooonnnnMMMMoooouuuusssseeeeOOOOvvvveeeerrrr, ----oooonnnnMMMMoooouuuusssseeeeOOOOuuuutttt and ----oooonnnnSSSSeeeelllleeeecccctttt parameters to register
  1698.              JavaScript event handlers.  The onChange handler will be called
  1699.              whenever the user changes the contents of the text field.  You
  1700.              can do text validation if you like.  onFocus and onBlur are
  1701.              called respectively when the insertion point moves into and out
  1702.              of the text field.  onSelect is called when the user changes the
  1703.              portion of the text that is selected.
  1704.  
  1705.      CCCCRRRREEEEAAAATTTTIIIINNNNGGGG AAAA BBBBIIIIGGGG TTTTEEEEXXXXTTTT FFFFIIIIEEEELLLLDDDD
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.                                                                        PPPPaaaaggggeeee 22226666
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  1721.  
  1722.  
  1723.  
  1724.         print $query->textarea(-name=>'foo',
  1725.                                -default=>'starting value',
  1726.                                -rows=>10,
  1727.                                -columns=>50);
  1728.  
  1729.              -or
  1730.  
  1731.         print $query->textarea('foo','starting value',10,50);
  1732.  
  1733.      _t_e_x_t_a_r_e_a() is just like textfield, but it allows you to specify rows and
  1734.      columns for a multiline text entry box.  You can provide a starting value
  1735.      for the field, which can be long and contain multiple lines.
  1736.  
  1737.      JAVASCRIPTING: The ----oooonnnnCCCChhhhaaaannnnggggeeee, ----oooonnnnFFFFooooccccuuuussss, ----oooonnnnBBBBlllluuuurrrr , ----oooonnnnMMMMoooouuuusssseeeeOOOOvvvveeeerrrr,
  1738.      ----oooonnnnMMMMoooouuuusssseeeeOOOOuuuutttt, and ----oooonnnnSSSSeeeelllleeeecccctttt parameters are recognized.  See _t_e_x_t_f_i_e_l_d().
  1739.  
  1740.      CCCCRRRREEEEAAAATTTTIIIINNNNGGGG AAAA PPPPAAAASSSSSSSSWWWWOOOORRRRDDDD FFFFIIIIEEEELLLLDDDD
  1741.  
  1742.         print $query->password_field(-name=>'secret',
  1743.                                      -value=>'starting value',
  1744.                                      -size=>50,
  1745.                                      -maxlength=>80);
  1746.              -or-
  1747.  
  1748.         print $query->password_field('secret','starting value',50,80);
  1749.  
  1750.      _p_a_s_s_w_o_r_d__f_i_e_l_d() is identical to _t_e_x_t_f_i_e_l_d(), except that its contents
  1751.      will be starred out on the web page.
  1752.  
  1753.      JAVASCRIPTING: The ----oooonnnnCCCChhhhaaaannnnggggeeee, ----oooonnnnFFFFooooccccuuuussss, ----oooonnnnBBBBlllluuuurrrr, ----oooonnnnMMMMoooouuuusssseeeeOOOOvvvveeeerrrr,
  1754.      ----oooonnnnMMMMoooouuuusssseeeeOOOOuuuutttt and ----oooonnnnSSSSeeeelllleeeecccctttt parameters are recognized.  See _t_e_x_t_f_i_e_l_d().
  1755.  
  1756.      CCCCRRRREEEEAAAATTTTIIIINNNNGGGG AAAA FFFFIIIILLLLEEEE UUUUPPPPLLLLOOOOAAAADDDD FFFFIIIIEEEELLLLDDDD
  1757.  
  1758.          print $query->filefield(-name=>'uploaded_file',
  1759.                                  -default=>'starting value',
  1760.                                  -size=>50,
  1761.                                  -maxlength=>80);
  1762.              -or-
  1763.  
  1764.          print $query->filefield('uploaded_file','starting value',50,80);
  1765.  
  1766.      _f_i_l_e_f_i_e_l_d() will return a file upload field for Netscape 2.0 browsers.
  1767.      In order to take full advantage of this _y_o_u _m_u_s_t _u_s_e _t_h_e _n_e_w _m_u_l_t_i_p_a_r_t
  1768.      _e_n_c_o_d_i_n_g _s_c_h_e_m_e for the form.  You can do this either by calling
  1769.      ssssttttaaaarrrrttttffffoooorrrrmmmm(((()))) with an encoding type of $$$$CCCCGGGGIIII::::::::MMMMUUUULLLLTTTTIIIIPPPPAAAARRRRTTTT, or by calling the
  1770.      new method ssssttttaaaarrrrtttt____mmmmuuuullllttttiiiippppaaaarrrrtttt____ffffoooorrrrmmmm(((()))) instead of vanilla ssssttttaaaarrrrttttffffoooorrrrmmmm(((()))).
  1771.  
  1772.      PPPPaaaarrrraaaammmmeeeetttteeeerrrrssss
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.                                                                        PPPPaaaaggggeeee 22227777
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  1787.  
  1788.  
  1789.  
  1790.      1.      The first parameter is the required name for the field (-name).
  1791.  
  1792.      2.      The optional second parameter is the starting value for the field
  1793.              contents to be used as the default file name (-default).
  1794.  
  1795.              The beta2 version of Netscape 2.0 currently doesn't pay any
  1796.              attention to this field, and so the starting value will always be
  1797.              blank.  Worse, the field loses its "sticky" behavior and forgets
  1798.              its previous contents.  The starting value field is called for in
  1799.              the HTML specification, however, and possibly later versions of
  1800.              Netscape will honor it.
  1801.  
  1802.      3.      The optional third parameter is the size of the field in
  1803.              characters (-size).
  1804.  
  1805.      4.      The optional fourth parameter is the maximum number of characters
  1806.              the field will accept (-maxlength).
  1807.  
  1808.              When the form is processed, you can retrieve the entered filename
  1809.              by calling _p_a_r_a_m().
  1810.  
  1811.                     $filename = $query->param('uploaded_file');
  1812.  
  1813.              In Netscape Navigator 2.0, the filename that gets returned is the
  1814.              full local filename on the rrrreeeemmmmooootttteeee uuuusssseeeerrrr''''ssss machine.  If the remote
  1815.              user is on a Unix machine, the filename will follow Unix
  1816.              conventions:
  1817.  
  1818.                      /path/to/the/file
  1819.  
  1820.              On an MS-DOS/Windows and OS/2 machines, the filename will follow
  1821.              DOS conventions:
  1822.  
  1823.                      C:\PATH\TO\THE\FILE.MSW
  1824.  
  1825.              On a Macintosh machine, the filename will follow Mac conventions:
  1826.  
  1827.                      HD 40:Desktop Folder:Sort Through:Reminders
  1828.  
  1829.              The filename returned is also a file handle.  You can read the
  1830.              contents of the file using standard Perl file reading calls:
  1831.  
  1832.                      # Read a text file and print it out
  1833.                      while (<$filename>) {
  1834.                         print;
  1835.                      }
  1836.  
  1837.                      # Copy a binary file to somewhere safe
  1838.                      open (OUTFILE,">>/usr/local/web/users/feedback");
  1839.                      while ($bytesread=read($filename,$buffer,1024)) {
  1840.                         print OUTFILE $buffer;
  1841.                      }
  1842.  
  1843.  
  1844.  
  1845.                                                                        PPPPaaaaggggeeee 22228888
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  1853.  
  1854.  
  1855.  
  1856.              When a file is uploaded the browser usually sends along some
  1857.              information along with it in the format of headers.  The
  1858.              information usually includes the MIME content type.  Future
  1859.              browsers may send other information as well (such as modification
  1860.              date and size). To retrieve this information, call _u_p_l_o_a_d_I_n_f_o().
  1861.              It returns a reference to an associative array containing all the
  1862.              document headers.
  1863.  
  1864.                     $filename = $query->param('uploaded_file');
  1865.                     $type = $query->uploadInfo($filename)->{'Content-Type'};
  1866.                     unless ($type eq 'text/html') {
  1867.                        die "HTML FILES ONLY!";
  1868.                     }
  1869.  
  1870.              If you are using a machine that recognizes "text" and "binary"
  1871.              data modes, be sure to understand when and how to use them (see
  1872.              the Camel book). Otherwise you may find that binary files are
  1873.              corrupted during file uploads.
  1874.  
  1875.              JAVASCRIPTING: The ----oooonnnnCCCChhhhaaaannnnggggeeee, ----oooonnnnFFFFooooccccuuuussss, ----oooonnnnBBBBlllluuuurrrr, ----oooonnnnMMMMoooouuuusssseeeeOOOOvvvveeeerrrr,
  1876.              ----oooonnnnMMMMoooouuuusssseeeeOOOOuuuutttt and ----oooonnnnSSSSeeeelllleeeecccctttt parameters are recognized.  See
  1877.              _t_e_x_t_f_i_e_l_d() for details.
  1878.  
  1879.      CCCCRRRREEEEAAAATTTTIIIINNNNGGGG AAAA PPPPOOOOPPPPUUUUPPPP MMMMEEEENNNNUUUU
  1880.  
  1881.         print $query->popup_menu('menu_name',
  1882.                                  ['eenie','meenie','minie'],
  1883.                                  'meenie');
  1884.  
  1885.            -or-
  1886.  
  1887.         %labels = ('eenie'=>'your first choice',
  1888.                    'meenie'=>'your second choice',
  1889.                    'minie'=>'your third choice');
  1890.         print $query->popup_menu('menu_name',
  1891.                                  ['eenie','meenie','minie'],
  1892.                                  'meenie',\%labels);
  1893.  
  1894.              -or (named parameter style)-
  1895.  
  1896.         print $query->popup_menu(-name=>'menu_name',
  1897.                                  -values=>['eenie','meenie','minie'],
  1898.                                  -default=>'meenie',
  1899.                                  -labels=>\%labels);
  1900.  
  1901.      _p_o_p_u_p__m_e_n_u() creates a menu.
  1902.  
  1903.      1.      The required first argument is the menu's name (-name).
  1904.  
  1905.      2.      The required second argument (-values) is an array rrrreeeeffffeeeerrrreeeennnncccceeee
  1906.              containing the list of menu items in the menu.  You can pass the
  1907.              method an anonymous array, as shown in the example, or a
  1908.  
  1909.  
  1910.  
  1911.                                                                        PPPPaaaaggggeeee 22229999
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  1919.  
  1920.  
  1921.  
  1922.              reference to a named array, such as "\@foo".
  1923.  
  1924.      3.      The optional third parameter (-default) is the name of the
  1925.              default menu choice.  If not specified, the first item will be
  1926.              the default.  The values of the previous choice will be
  1927.              maintained across queries.
  1928.  
  1929.      4.      The optional fourth parameter (-labels) is provided for people
  1930.              who want to use different values for the user-visible label
  1931.              inside the popup menu nd the value returned to your script.  It's
  1932.              a pointer to an associative array relating menu values to user-
  1933.              visible labels.  If you leave this parameter blank, the menu
  1934.              values will be displayed by default.  (You can also leave a label
  1935.              undefined if you want to).
  1936.  
  1937.              When the form is processed, the selected value of the popup menu
  1938.              can be retrieved using:
  1939.  
  1940.                    $popup_menu_value = $query->param('menu_name');
  1941.  
  1942.              JAVASCRIPTING: _p_o_p_u_p__m_e_n_u() recognizes the following event
  1943.              handlers:  ----oooonnnnCCCChhhhaaaannnnggggeeee, ----oooonnnnFFFFooooccccuuuussss, ----oooonnnnMMMMoooouuuusssseeeeOOOOvvvveeeerrrr, ----oooonnnnMMMMoooouuuusssseeeeOOOOuuuutttt, and
  1944.              ----oooonnnnBBBBlllluuuurrrr.  See the _t_e_x_t_f_i_e_l_d() section for details on when these
  1945.              handlers are called.
  1946.  
  1947.      CCCCRRRREEEEAAAATTTTIIIINNNNGGGG AAAA SSSSCCCCRRRROOOOLLLLLLLLIIIINNNNGGGG LLLLIIIISSSSTTTT
  1948.  
  1949.         print $query->scrolling_list('list_name',
  1950.                                      ['eenie','meenie','minie','moe'],
  1951.                                      ['eenie','moe'],5,'true');
  1952.            -or-
  1953.  
  1954.         print $query->scrolling_list('list_name',
  1955.                                      ['eenie','meenie','minie','moe'],
  1956.                                      ['eenie','moe'],5,'true',
  1957.                                      \%labels);
  1958.  
  1959.              -or-
  1960.  
  1961.         print $query->scrolling_list(-name=>'list_name',
  1962.                                      -values=>['eenie','meenie','minie','moe'],
  1963.                                      -default=>['eenie','moe'],
  1964.                                      -size=>5,
  1965.                                      -multiple=>'true',
  1966.                                      -labels=>\%labels);
  1967.  
  1968.      _s_c_r_o_l_l_i_n_g__l_i_s_t() creates a scrolling list.
  1969.  
  1970.      PPPPaaaarrrraaaammmmeeeetttteeeerrrrssss::::
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.                                                                        PPPPaaaaggggeeee 33330000
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  1985.  
  1986.  
  1987.  
  1988.      1.      The first and second arguments are the list name (-name) and
  1989.              values (-values).  As in the popup menu, the second argument
  1990.              should be an array reference.
  1991.  
  1992.      2.      The optional third argument (-default) can be either a reference
  1993.              to a list containing the values to be selected by default, or can
  1994.              be a single value to select.  If this argument is missing or
  1995.              undefined, then nothing is selected when the list first appears.
  1996.              In the named parameter version, you can use the synonym
  1997.              "-defaults" for this parameter.
  1998.  
  1999.      3.      The optional fourth argument is the size of the list (-size).
  2000.  
  2001.      4.      The optional fifth argument can be set to true to allow multiple
  2002.              simultaneous selections (-multiple).  Otherwise only one
  2003.              selection will be allowed at a time.
  2004.  
  2005.      5.      The optional sixth argument is a pointer to an associative array
  2006.              containing long user-visible labels for the list items (-labels).
  2007.              If not provided, the values will be displayed.
  2008.  
  2009.              When this form is processed, all selected list items will be
  2010.              returned as a list under the parameter name 'list_name'.  The
  2011.              values of the selected items can be retrieved with:
  2012.  
  2013.                    @selected = $query->param('list_name');
  2014.  
  2015.  
  2016.              JAVASCRIPTING: _s_c_r_o_l_l_i_n_g__l_i_s_t() recognizes the following event
  2017.              handlers: ----oooonnnnCCCChhhhaaaannnnggggeeee, ----oooonnnnFFFFooooccccuuuussss, ----oooonnnnMMMMoooouuuusssseeeeOOOOvvvveeeerrrr, ----oooonnnnMMMMoooouuuusssseeeeOOOOuuuutttt and
  2018.              ----oooonnnnBBBBlllluuuurrrr.  See _t_e_x_t_f_i_e_l_d() for the description of when these
  2019.              handlers are called.
  2020.  
  2021.      CCCCRRRREEEEAAAATTTTIIIINNNNGGGG AAAA GGGGRRRROOOOUUUUPPPP OOOOFFFF RRRREEEELLLLAAAATTTTEEEEDDDD CCCCHHHHEEEECCCCKKKKBBBBOOOOXXXXEEEESSSS
  2022.  
  2023.         print $query->checkbox_group(-name=>'group_name',
  2024.                                      -values=>['eenie','meenie','minie','moe'],
  2025.                                      -default=>['eenie','moe'],
  2026.                                      -linebreak=>'true',
  2027.                                      -labels=>\%labels);
  2028.  
  2029.         print $query->checkbox_group('group_name',
  2030.                                      ['eenie','meenie','minie','moe'],
  2031.                                      ['eenie','moe'],'true',\%labels);
  2032.  
  2033.         HTML3-COMPATIBLE BROWSERS ONLY:
  2034.  
  2035.         print $query->checkbox_group(-name=>'group_name',
  2036.                                      -values=>['eenie','meenie','minie','moe'],
  2037.                                      -rows=2,-columns=>2);
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.                                                                        PPPPaaaaggggeeee 33331111
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  2051.  
  2052.  
  2053.  
  2054.      _c_h_e_c_k_b_o_x__g_r_o_u_p() creates a list of checkboxes that are related by the
  2055.      same name.
  2056.  
  2057.      PPPPaaaarrrraaaammmmeeeetttteeeerrrrssss::::
  2058.  
  2059.      1.      The first and second arguments are the checkbox name and values,
  2060.              respectively (-name and -values).  As in the popup menu, the
  2061.              second argument should be an array reference.  These values are
  2062.              used for the user-readable labels printed next to the checkboxes
  2063.              as well as for the values passed to your script in the query
  2064.              string.
  2065.  
  2066.      2.      The optional third argument (-default) can be either a reference
  2067.              to a list containing the values to be checked by default, or can
  2068.              be a single value to checked.  If this argument is missing or
  2069.              undefined, then nothing is selected when the list first appears.
  2070.  
  2071.      3.      The optional fourth argument (-linebreak) can be set to true to
  2072.              place line breaks between the checkboxes so that they appear as a
  2073.              vertical list.  Otherwise, they will be strung together on a
  2074.              horizontal line.
  2075.  
  2076.      4.      The optional fifth argument is a pointer to an associative array
  2077.              relating the checkbox values to the user-visible labels that will
  2078.              be printed next to them (-labels).  If not provided, the values
  2079.              will be used as the default.
  2080.  
  2081.      5.      HHHHTTTTMMMMLLLL3333----ccccoooommmmppppaaaattttiiiibbbblllleeee bbbbrrrroooowwwwsssseeeerrrrssss (such as Netscape) can take advantage
  2082.              of the optional parameters ----rrrroooowwwwssss, and ----ccccoooolllluuuummmmnnnnssss.  These parameters
  2083.              cause _c_h_e_c_k_b_o_x__g_r_o_u_p() to return an HTML3 compatible table
  2084.              containing the checkbox group formatted with the specified number
  2085.              of rows and columns.  You can provide just the -columns parameter
  2086.              if you wish; checkbox_group will calculate the correct number of
  2087.              rows for you.
  2088.  
  2089.              To include row and column headings in the returned table, you can
  2090.              use the ----rrrroooowwwwhhhheeeeaaaaddddeeeerrrrssss and ----ccccoooollllhhhheeeeaaaaddddeeeerrrrssss parameters.  Both of these
  2091.              accept a pointer to an array of headings to use.  The headings
  2092.              are just decorative.  They don't reorganize the interpretation of
  2093.              the checkboxes -- they're still a single named unit.
  2094.  
  2095.              When the form is processed, all checked boxes will be returned as
  2096.              a list under the parameter name 'group_name'.  The values of the
  2097.              "on" checkboxes can be retrieved with:
  2098.  
  2099.                    @turned_on = $query->param('group_name');
  2100.  
  2101.              The value returned by _c_h_e_c_k_b_o_x__g_r_o_u_p() is actually an array of
  2102.              button elements.  You can capture them and use them within
  2103.              tables, lists, or in other creative ways:
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.                                                                        PPPPaaaaggggeeee 33332222
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  2117.  
  2118.  
  2119.  
  2120.                  @h = $query->checkbox_group(-name=>'group_name',-values=>\@values);
  2121.                  &use_in_creative_way(@h);
  2122.  
  2123.              JAVASCRIPTING: _c_h_e_c_k_b_o_x__g_r_o_u_p() recognizes the ----oooonnnnCCCClllliiiicccckkkk
  2124.              parameter.  This specifies a JavaScript code fragment or function
  2125.              call to be executed every time the user clicks on any of the
  2126.              buttons in the group.  You can retrieve the identity of the
  2127.              particular button clicked on using the "this" variable.
  2128.  
  2129.      CCCCRRRREEEEAAAATTTTIIIINNNNGGGG AAAA SSSSTTTTAAAANNNNDDDDAAAALLLLOOOONNNNEEEE CCCCHHHHEEEECCCCKKKKBBBBOOOOXXXX
  2130.  
  2131.          print $query->checkbox(-name=>'checkbox_name',
  2132.                                 -checked=>'checked',
  2133.                                 -value=>'ON',
  2134.                                 -label=>'CLICK ME');
  2135.  
  2136.              -or-
  2137.  
  2138.          print $query->checkbox('checkbox_name','checked','ON','CLICK ME');
  2139.  
  2140.      _c_h_e_c_k_b_o_x() is used to create an isolated checkbox that isn't logically
  2141.      related to any others.
  2142.  
  2143.      PPPPaaaarrrraaaammmmeeeetttteeeerrrrssss::::
  2144.  
  2145.      1.      The first parameter is the required name for the checkbox
  2146.              (-name).  It will also be used for the user-readable label
  2147.              printed next to the checkbox.
  2148.  
  2149.      2.      The optional second parameter (-checked) specifies that the
  2150.              checkbox is turned on by default.  Synonyms are -selected and
  2151.              -on.
  2152.  
  2153.      3.      The optional third parameter (-value) specifies the value of the
  2154.              checkbox when it is checked.  If not provided, the word "on" is
  2155.              assumed.
  2156.  
  2157.      4.      The optional fourth parameter (-label) is the user-readable label
  2158.              to be attached to the checkbox.  If not provided, the checkbox
  2159.              name is used.
  2160.  
  2161.              The value of the checkbox can be retrieved using:
  2162.  
  2163.                  $turned_on = $query->param('checkbox_name');
  2164.  
  2165.              JAVASCRIPTING: _c_h_e_c_k_b_o_x() recognizes the ----oooonnnnCCCClllliiiicccckkkk parameter.  See
  2166.              _c_h_e_c_k_b_o_x__g_r_o_u_p() for further details.
  2167.  
  2168.      CCCCRRRREEEEAAAATTTTIIIINNNNGGGG AAAA RRRRAAAADDDDIIIIOOOO BBBBUUUUTTTTTTTTOOOONNNN GGGGRRRROOOOUUUUPPPP
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.                                                                        PPPPaaaaggggeeee 33333333
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  2183.  
  2184.  
  2185.  
  2186.         print $query->radio_group(-name=>'group_name',
  2187.                                   -values=>['eenie','meenie','minie'],
  2188.                                   -default=>'meenie',
  2189.                                   -linebreak=>'true',
  2190.                                   -labels=>\%labels);
  2191.  
  2192.              -or-
  2193.  
  2194.         print $query->radio_group('group_name',['eenie','meenie','minie'],
  2195.                                                'meenie','true',\%labels);
  2196.  
  2197.         HTML3-COMPATIBLE BROWSERS ONLY:
  2198.  
  2199.         print $query->radio_group(-name=>'group_name',
  2200.                                   -values=>['eenie','meenie','minie','moe'],
  2201.                                   -rows=2,-columns=>2);
  2202.  
  2203.      _r_a_d_i_o__g_r_o_u_p() creates a set of logically-related radio buttons (turning
  2204.      one member of the group on turns the others off)
  2205.  
  2206.      PPPPaaaarrrraaaammmmeeeetttteeeerrrrssss::::
  2207.  
  2208.      1.      The first argument is the name of the group and is required
  2209.              (-name).
  2210.  
  2211.      2.      The second argument (-values) is the list of values for the radio
  2212.              buttons.  The values and the labels that appear on the page are
  2213.              identical.  Pass an array _r_e_f_e_r_e_n_c_e in the second argument,
  2214.              either using an anonymous array, as shown, or by referencing a
  2215.              named array as in "\@foo".
  2216.  
  2217.      3.      The optional third parameter (-default) is the name of the
  2218.              default button to turn on. If not specified, the first item will
  2219.              be the default.  You can provide a nonexistent button name, such
  2220.              as "-" to start up with no buttons selected.
  2221.  
  2222.      4.      The optional fourth parameter (-linebreak) can be set to 'true'
  2223.              to put line breaks between the buttons, creating a vertical list.
  2224.  
  2225.      5.      The optional fifth parameter (-labels) is a pointer to an
  2226.              associative array relating the radio button values to user-
  2227.              visible labels to be used in the display.  If not provided, the
  2228.              values themselves are displayed.
  2229.  
  2230.      6.      HHHHTTTTMMMMLLLL3333----ccccoooommmmppppaaaattttiiiibbbblllleeee bbbbrrrroooowwwwsssseeeerrrrssss (such as Netscape) can take advantage
  2231.              of the optional parameters ----rrrroooowwwwssss, and ----ccccoooolllluuuummmmnnnnssss.  These parameters
  2232.              cause _r_a_d_i_o__g_r_o_u_p() to return an HTML3 compatible table
  2233.              containing the radio group formatted with the specified number of
  2234.              rows and columns.  You can provide just the -columns parameter if
  2235.              you wish; radio_group will calculate the correct number of rows
  2236.              for you.
  2237.  
  2238.  
  2239.  
  2240.  
  2241.                                                                        PPPPaaaaggggeeee 33334444
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  2249.  
  2250.  
  2251.  
  2252.              To include row and column headings in the returned table, you can
  2253.              use the ----rrrroooowwwwhhhheeeeaaaaddddeeeerrrr and ----ccccoooollllhhhheeeeaaaaddddeeeerrrr parameters.  Both of these
  2254.              accept a pointer to an array of headings to use.  The headings
  2255.              are just decorative.  They don't reorganize the interpetation of
  2256.              the radio buttons -- they're still a single named unit.
  2257.  
  2258.              When the form is processed, the selected radio button can be
  2259.              retrieved using:
  2260.  
  2261.                    $which_radio_button = $query->param('group_name');
  2262.  
  2263.              The value returned by _r_a_d_i_o__g_r_o_u_p() is actually an array of
  2264.              button elements.  You can capture them and use them within
  2265.              tables, lists, or in other creative ways:
  2266.  
  2267.                  @h = $query->radio_group(-name=>'group_name',-values=>\@values);
  2268.                  &use_in_creative_way(@h);
  2269.  
  2270.  
  2271.      CCCCRRRREEEEAAAATTTTIIIINNNNGGGG AAAA SSSSUUUUBBBBMMMMIIIITTTT BBBBUUUUTTTTTTTTOOOONNNN
  2272.  
  2273.         print $query->submit(-name=>'button_name',
  2274.                              -value=>'value');
  2275.  
  2276.              -or-
  2277.  
  2278.         print $query->submit('button_name','value');
  2279.  
  2280.      _s_u_b_m_i_t() will create the query submission button.  Every form should have
  2281.      one of these.
  2282.  
  2283.      PPPPaaaarrrraaaammmmeeeetttteeeerrrrssss::::
  2284.  
  2285.      1.      The first argument (-name) is optional.  You can give the button
  2286.              a name if you have several submission buttons in your form and
  2287.              you want to distinguish between them.  The name will also be used
  2288.              as the user-visible label.  Be aware that a few older browsers
  2289.              don't deal with this correctly and nnnneeeevvvveeeerrrr send back a value from a
  2290.              button.
  2291.  
  2292.      2.      The second argument (-value) is also optional.  This gives the
  2293.              button a value that will be passed to your script in the query
  2294.              string.
  2295.  
  2296.              You can figure out which button was pressed by using different
  2297.              values for each one:
  2298.  
  2299.                   $which_one = $query->param('button_name');
  2300.  
  2301.              JAVASCRIPTING: _r_a_d_i_o__g_r_o_u_p() recognizes the ----oooonnnnCCCClllliiiicccckkkk parameter.
  2302.              See _c_h_e_c_k_b_o_x__g_r_o_u_p() for further details.
  2303.  
  2304.  
  2305.  
  2306.  
  2307.                                                                        PPPPaaaaggggeeee 33335555
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  2315.  
  2316.  
  2317.  
  2318.      CCCCRRRREEEEAAAATTTTIIIINNNNGGGG AAAA RRRREEEESSSSEEEETTTT BBBBUUUUTTTTTTTTOOOONNNN
  2319.  
  2320.         print $query->reset
  2321.  
  2322.      _r_e_s_e_t() creates the "reset" button.  Note that it restores the form to
  2323.      its value from the last time the script was called, NOT necessarily to
  2324.      the defaults.
  2325.  
  2326.      CCCCRRRREEEEAAAATTTTIIIINNNNGGGG AAAA DDDDEEEEFFFFAAAAUUUULLLLTTTT BBBBUUUUTTTTTTTTOOOONNNN
  2327.  
  2328.         print $query->defaults('button_label')
  2329.  
  2330.      _d_e_f_a_u_l_t_s() creates a button that, when invoked, will cause the form to be
  2331.      completely reset to its defaults, wiping out all the changes the user
  2332.      ever made.
  2333.  
  2334.      CCCCRRRREEEEAAAATTTTIIIINNNNGGGG AAAA HHHHIIIIDDDDDDDDEEEENNNN FFFFIIIIEEEELLLLDDDD
  2335.  
  2336.              print $query->hidden(-name=>'hidden_name',
  2337.                                   -default=>['value1','value2'...]);
  2338.  
  2339.                      -or-
  2340.  
  2341.              print $query->hidden('hidden_name','value1','value2'...);
  2342.  
  2343.      _h_i_d_d_e_n() produces a text field that can't be seen by the user.  It is
  2344.      useful for passing state variable information from one invocation of the
  2345.      script to the next.
  2346.  
  2347.      PPPPaaaarrrraaaammmmeeeetttteeeerrrrssss::::
  2348.  
  2349.      1.      The first argument is required and specifies the name of this
  2350.              field (-name).
  2351.  
  2352.      2.      The second argument is also required and specifies its value
  2353.              (-default).  In the named parameter style of calling, you can
  2354.              provide a single value here or a reference to a whole list
  2355.  
  2356.              Fetch the value of a hidden field this way:
  2357.  
  2358.                   $hidden_value = $query->param('hidden_name');
  2359.  
  2360.              Note, that just like all the other form elements, the value of a
  2361.              hidden field is "sticky".  If you want to replace a hidden field
  2362.              with some other values after the script has been called once
  2363.              you'll have to do it manually:
  2364.  
  2365.                   $query->param('hidden_name','new','values','here');
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.  
  2372.  
  2373.                                                                        PPPPaaaaggggeeee 33336666
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  2381.  
  2382.  
  2383.  
  2384.      CCCCRRRREEEEAAAATTTTIIIINNNNGGGG AAAA CCCCLLLLIIIICCCCKKKKAAAABBBBLLLLEEEE IIIIMMMMAAAAGGGGEEEE BBBBUUUUTTTTTTTTOOOONNNN
  2385.  
  2386.           print $query->image_button(-name=>'button_name',
  2387.                                      -src=>'/source/URL',
  2388.                                      -align=>'MIDDLE');
  2389.  
  2390.              -or-
  2391.  
  2392.           print $query->image_button('button_name','/source/URL','MIDDLE');
  2393.  
  2394.      _i_m_a_g_e__b_u_t_t_o_n() produces a clickable image.  When it's clicked on the
  2395.      position of the click is returned to your script as "button_name.x" and
  2396.      "button_name.y", where "button_name" is the name you've assigned to it.
  2397.  
  2398.      JAVASCRIPTING: _i_m_a_g_e__b_u_t_t_o_n() recognizes the ----oooonnnnCCCClllliiiicccckkkk parameter.  See
  2399.      _c_h_e_c_k_b_o_x__g_r_o_u_p() for further details.
  2400.  
  2401.      PPPPaaaarrrraaaammmmeeeetttteeeerrrrssss::::
  2402.  
  2403.      1.      The first argument (-name) is required and specifies the name of
  2404.              this field.
  2405.  
  2406.      2.      The second argument (-src) is also required and specifies the URL
  2407.  
  2408. BOTTOM or MIDDLE
  2409.      3. The third option (-align, optional) is an alignment type, and may be TOP,
  2410.  
  2411.              Fetch the value of the button this way:
  2412.                   $x = $query->_p_a_r_a_m('button_name.x');
  2413.                   $y = $query->_p_a_r_a_m('button_name.y');
  2414.  
  2415.      CCCCRRRREEEEAAAATTTTIIIINNNNGGGG AAAA JJJJAAAAVVVVAAAASSSSCCCCRRRRIIIIPPPPTTTT AAAACCCCTTTTIIIIOOOONNNN BBBBUUUUTTTTTTTTOOOONNNN
  2416.  
  2417.           print $query->button(-name=>'button_name',
  2418.                                -value=>'user visible label',
  2419.                                -onClick=>"do_something()");
  2420.  
  2421.              -or-
  2422.  
  2423.           print $query->button('button_name',"do_something()");
  2424.  
  2425.      _b_u_t_t_o_n() produces a button that is compatible with Netscape 2.0's
  2426.      JavaScript.  When it's pressed the fragment of JavaScript code pointed to
  2427.      by the ----oooonnnnCCCClllliiiicccckkkk parameter will be executed.  On non-Netscape browsers
  2428.      this form element will probably not even display.
  2429.  
  2430. NNNNEEEETTTTSSSSCCCCAAAAPPPPEEEE CCCCOOOOOOOOKKKKIIIIEEEESSSS
  2431.      Netscape browsers versions 1.1 and higher support a so-called "cookie"
  2432.      designed to help maintain state within a browser session.  CGI.pm has
  2433.      several methods that support cookies.
  2434.  
  2435.      A cookie is a name=value pair much like the named parameters in a CGI
  2436.  
  2437.  
  2438.  
  2439.                                                                        PPPPaaaaggggeeee 33337777
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  2447.  
  2448.  
  2449.  
  2450.      query string.  CGI scripts create one or more cookies and send them to
  2451.      the browser in the HTTP header.  The browser maintains a list of cookies
  2452.      that belong to a particular Web server, and returns them to the CGI
  2453.      script during subsequent interactions.
  2454.  
  2455.      In addition to the required name=value pair, each cookie has several
  2456.      optional attributes:
  2457.  
  2458.      1. an expiration time
  2459.              This is a time/date string (in a special GMT format) that
  2460.              indicates when a cookie expires.  The cookie will be saved and
  2461.              returned to your script until this expiration date is reached if
  2462.              the user exits Netscape and restarts it.  If an expiration date
  2463.              isn't specified, the cookie will remain active until the user
  2464.              quits Netscape.
  2465.  
  2466.      2. a domain
  2467.              This is a partial or complete domain name for which the cookie is
  2468.              valid.  The browser will return the cookie to any host that
  2469.              matches the partial domain name.  For example, if you specify a
  2470.              domain name of ".capricorn.com", then Netscape will return the
  2471.              cookie to Web servers running on any of the machines
  2472.              "www.capricorn.com", "www2.capricorn.com",
  2473.              "feckless.capricorn.com", etc.  Domain names must contain at
  2474.              least two periods to prevent attempts to match on top level
  2475.              domains like ".edu".  If no domain is specified, then the browser
  2476.              will only return the cookie to servers on the host the cookie
  2477.              originated from.
  2478.  
  2479.      3. a path
  2480.              If you provide a cookie path attribute, the browser will check it
  2481.              against your script's URL before returning the cookie.  For
  2482.              example, if you specify the path "/cgi-bin", then the cookie will
  2483.              be returned to each of the scripts "/cgi-bin/tally.pl", "/cgi-
  2484.              bin/order.pl", and "/cgi-bin/customer_service/complain.pl", but
  2485.              not to the script "/cgi-private/site_admin.pl".  By default, path
  2486.              is set to "/", which causes the cookie to be sent to any CGI
  2487.              script on your site.
  2488.  
  2489.      4. a "secure" flag
  2490.              If the "secure" attribute is set, the cookie will only be sent to
  2491.              your script if the CGI request is occurring on a secure channel,
  2492.              such as SSL.
  2493.  
  2494.              The interface to Netscape cookies is the ccccooooooookkkkiiiieeee(((()))) method:
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.                                                                        PPPPaaaaggggeeee 33338888
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  2513.  
  2514.  
  2515.  
  2516.                  $cookie = $query->cookie(-name=>'sessionID',
  2517.                                           -value=>'xyzzy',
  2518.                                           -expires=>'+1h',
  2519.                                           -path=>'/cgi-bin/database',
  2520.                                           -domain=>'.capricorn.org',
  2521.                                           -secure=>1);
  2522.                  print $query->header(-cookie=>$cookie);
  2523.  
  2524.              ccccooooooookkkkiiiieeee(((()))) creates a new cookie.  Its parameters include:
  2525.  
  2526.      ----nnnnaaaammmmeeee   The name of the cookie (required).  This can be any string at
  2527.              all.  Although Netscape limits its cookie names to non-whitespace
  2528.              alphanumeric characters, CGI.pm removes this restriction by
  2529.              escaping and unescaping cookies behind the scenes.
  2530.  
  2531.      ----vvvvaaaalllluuuueeee  The value of the cookie.  This can be any scalar value, array
  2532.              reference, or even associative array reference.  For example, you
  2533.              can store an entire associative array into a cookie this way:
  2534.  
  2535.                      $cookie=$query->cookie(-name=>'family information',
  2536.                                             -value=>\%childrens_ages);
  2537.  
  2538.  
  2539.      ----ppppaaaatttthhhh   The optional partial path for which this cookie will be valid, as
  2540.              described above.
  2541.  
  2542.      ----ddddoooommmmaaaaiiiinnnn The optional partial domain for which this cookie will be valid,
  2543.              as described above.
  2544.  
  2545.      ----eeeexxxxppppiiiirrrreeeessss
  2546.              The optional expiration date for this cookie.  The format is as
  2547.              described in the section on the hhhheeeeaaaaddddeeeerrrr(((()))) method:
  2548.  
  2549.                      "+1h"  one hour from now
  2550.  
  2551.  
  2552.      ----sssseeeeccccuuuurrrreeee If set to true, this cookie will only be used within a secure SSL
  2553.              session.
  2554.  
  2555.              The cookie created by _c_o_o_k_i_e() must be incorporated into the HTTP
  2556.              header within the string returned by the _h_e_a_d_e_r() method:
  2557.  
  2558.                      print $query->header(-cookie=>$my_cookie);
  2559.  
  2560.              To create multiple cookies, give _h_e_a_d_e_r() an array reference:
  2561.  
  2562.                      $cookie1 = $query->cookie(-name=>'riddle_name',
  2563.                                                -value=>"The Sphynx's Question");
  2564.                      $cookie2 = $query->cookie(-name=>'answers',
  2565.                                                -value=>\%answers);
  2566.                      print $query->header(-cookie=>[$cookie1,$cookie2]);
  2567.  
  2568.  
  2569.  
  2570.  
  2571.                                                                        PPPPaaaaggggeeee 33339999
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  2579.  
  2580.  
  2581.  
  2582.              To retrieve a cookie, request it by name by calling _c_o_o_k_i_e()
  2583.              method without the ----vvvvaaaalllluuuueeee parameter:
  2584.  
  2585.                      use CGI;
  2586.                      $query = new CGI;
  2587.                      %answers = $query->cookie(-name=>'answers');
  2588.                      # $query->cookie('answers') will work too!
  2589.  
  2590.              The cookie and CGI namespaces are separate.  If you have a
  2591.              parameter named 'answers' and a cookie named 'answers', the
  2592.              values retrieved by _p_a_r_a_m() and _c_o_o_k_i_e() are independent of each
  2593.              other.  However, it's simple to turn a CGI parameter into a
  2594.              cookie, and vice-versa:
  2595.  
  2596.                 # turn a CGI parameter into a cookie
  2597.                 $c=$q->cookie(-name=>'answers',-value=>[$q->param('answers')]);
  2598.                 # vice-versa
  2599.                 $q->param(-name=>'answers',-value=>[$q->cookie('answers')]);
  2600.  
  2601.              See the ccccooooooookkkkiiiieeee....ccccggggiiii example script for some ideas on how to use
  2602.              cookies effectively.
  2603.  
  2604.              NNNNOOOOTTTTEEEE:::: There appear to be some (undocumented) restrictions on
  2605.              Netscape cookies.  In Netscape 2.01, at least, I haven't been
  2606.              able to set more than three cookies at a time.  There may also be
  2607.              limits on the length of cookies.  If you need to store a lot of
  2608.              information, it's probably better to create a unique session ID,
  2609.              store it in a cookie, and use the session ID to locate an
  2610.              external file/database saved on the server's side of the
  2611.              connection.
  2612.  
  2613. WWWWOOOORRRRKKKKIIIINNNNGGGG WWWWIIIITTTTHHHH NNNNEEEETTTTSSSSCCCCAAAAPPPPEEEE FFFFRRRRAAAAMMMMEEEESSSS
  2614.      It's possible for CGI.pm scripts to write into several browser panels and
  2615.      windows using Netscape's frame mechanism. There are three techniques for
  2616.      defining new frames programmatically:
  2617.  
  2618.      1. Create a <Frameset> document
  2619.              After writing out the HTTP header, instead of creating a standard
  2620.              HTML document using the _s_t_a_r_t__h_t_m_l() call, create a <FRAMESET>
  2621.              document that defines the frames on the page.  Specify your
  2622.              _s_c_r_i_p_t(s) (with appropriate parameters) as the SRC for each of
  2623.              the frames.
  2624.  
  2625.              There is no specific support for creating <FRAMESET> sections in
  2626.              CGI.pm, but the HTML is very simple to write.  See the frame
  2627.              documentation in Netscape's home pages for details
  2628.  
  2629.                http://home.netscape.com/assist/net_sites/frames.html
  2630.  
  2631.  
  2632.  
  2633.  
  2634.  
  2635.  
  2636.  
  2637.                                                                        PPPPaaaaggggeeee 44440000
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  2645.  
  2646.  
  2647.  
  2648.      2. Specify the destination for the document in the HTTP header
  2649.              You may provide a ----ttttaaaarrrrggggeeeetttt parameter to the _h_e_a_d_e_r() method:
  2650.  
  2651.                  print $q->_h_e_a_d_e_r(-target=>'ResultsWindow');
  2652.  
  2653.              This will tell Netscape to load the output of your script into
  2654.              the frame named "ResultsWindow".  If a frame of that name doesn't
  2655.              already exist, Netscape will pop up a new window and load your
  2656.              script's document into that.  There are a number of magic names
  2657.              that you can use for targets.  See the frame documents on
  2658.              Netscape's home pages for details.
  2659.  
  2660.      3. Specify the destination for the document in the <FORM> tag
  2661.              You can specify the frame to load in the FORM tag itself.  With
  2662.              CGI.pm it looks like this:
  2663.  
  2664.                  print $q->startform(-target=>'ResultsWindow');
  2665.  
  2666.              When your script is reinvoked by the form, its output will be
  2667.              loaded into the frame named "ResultsWindow".  If one doesn't
  2668.              already exist a new window will be created.
  2669.  
  2670.              The script "frameset.cgi" in the examples directory shows one way
  2671.              to create pages in which the fill-out form and the response live
  2672.              in side-by-side frames.
  2673.  
  2674. LLLLIIIIMMMMIIIITTTTEEEEDDDD SSSSUUUUPPPPPPPPOOOORRRRTTTT FFFFOOOORRRR CCCCAAAASSSSCCCCAAAADDDDIIIINNNNGGGG SSSSTTTTYYYYLLLLEEEE SSSSHHHHEEEEEEEETTTTSSSS
  2675.      CGI.pm has limited support for HTML3's cascading style sheets (css).  To
  2676.      incorporate a stylesheet into your document, pass the _s_t_a_r_t__h_t_m_l() method
  2677.      a ----ssssttttyyyylllleeee parameter.  The value of this parameter may be a scalar, in
  2678.      which case it is incorporated directly into a <STYLE> section, or it may
  2679.      be a hash reference.  In the latter case you should provide the hash with
  2680.      one or more of ----ssssrrrrcccc or ----ccccooooddddeeee.  ----ssssrrrrcccc points to a URL where an externally-
  2681.      defined stylesheet can be found.  ----ccccooooddddeeee points to a scalar value to be
  2682.      incorporated into a <STYLE> section.  Style definitions in ----ccccooooddddeeee override
  2683.      similarly-named ones in ----ssssrrrrcccc, hence the name "cascading."
  2684.  
  2685.      You may also specify the type of the stylesheet by adding the optional
  2686.      ----ttttyyyyppppeeee parameter to the hash pointed to by ----ssssttttyyyylllleeee.  If not specified, the
  2687.      style defaults to 'text/css'.
  2688.  
  2689.      To refer to a style within the body of your document, add the ----ccccllllaaaassssssss
  2690.      parameter to any HTML element:
  2691.  
  2692.          print h1({-class=>'Fancy'},'Welcome to the Party');
  2693.  
  2694.      Or define styles on the fly with the ----ssssttttyyyylllleeee parameter:
  2695.  
  2696.          print h1({-style=>'Color: red;'},'Welcome to Hell');
  2697.  
  2698.      You may also use the new ssssppppaaaannnn(((()))) element to apply a style to a section of
  2699.      text:
  2700.  
  2701.  
  2702.  
  2703.                                                                        PPPPaaaaggggeeee 44441111
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  2711.  
  2712.  
  2713.  
  2714.          print span({-style=>'Color: red;'},
  2715.                     h1('Welcome to Hell'),
  2716.                     "Where did that handbasket get to?"
  2717.                     );
  2718.  
  2719.      Note that you must import the ":html3" definitions to have the ssssppppaaaannnn(((())))
  2720.      method available.  Here's a quick and dirty example of using CSS's.  See
  2721.      the CSS specification at http://www.w3.org/pub/WWW/TR/Wd-css-1.html for
  2722.      more information.
  2723.  
  2724.          use CGI qw/:standard :html3/;
  2725.  
  2726.          #here's a stylesheet incorporated directly into the page
  2727.          $newStyle=<<END;
  2728.          <!--
  2729.          P.Tip {
  2730.              margin-right: 50pt;
  2731.              margin-left: 50pt;
  2732.              color: red;
  2733.          }
  2734.          P.Alert {
  2735.              font-size: 30pt;
  2736.              font-family: sans-serif;
  2737.            color: red;
  2738.          }
  2739.          -->
  2740.          END
  2741.          print header();
  2742.          print start_html( -title=>'CGI with Style',
  2743.                            -style=>{-src=>'http://www.capricorn.com/style/st1.css',
  2744.                                     -code=>$newStyle}
  2745.                           );
  2746.          print h1('CGI with Style'),
  2747.                p({-class=>'Tip'},
  2748.                  "Better read the cascading style sheet spec before playing with this!"),
  2749.                span({-style=>'color: magenta'},
  2750.                     "Look Mom, no hands!",
  2751.                     p(),
  2752.                     "Whooo wee!"
  2753.                     );
  2754.          print end_html;
  2755.  
  2756.  
  2757. DDDDEEEEBBBBUUUUGGGGGGGGIIIINNNNGGGG
  2758.      If you are running the script from the command line or in the perl
  2759.      debugger, you can pass the script a list of keywords or parameter=value
  2760.      pairs on the command line or from standard input (you don't have to worry
  2761.      about tricking your script into reading from environment variables).  You
  2762.      can pass keywords like this:
  2763.  
  2764.          your_script.pl keyword1 keyword2 keyword3
  2765.  
  2766.  
  2767.  
  2768.  
  2769.                                                                        PPPPaaaaggggeeee 44442222
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  2777.  
  2778.  
  2779.  
  2780.      or this:
  2781.  
  2782.         your_script.pl keyword1+keyword2+keyword3
  2783.  
  2784.      or this:
  2785.  
  2786.          your_script.pl name1=value1 name2=value2
  2787.  
  2788.      or this:
  2789.  
  2790.          your_script.pl name1=value1&name2=value2
  2791.  
  2792.      or even as newline-delimited parameters on standard input.
  2793.  
  2794.      When debugging, you can use quotes and backslashes to escape characters
  2795.      in the familiar shell manner, letting you place spaces and other funny
  2796.      characters in your parameter=value pairs:
  2797.  
  2798.         your_script.pl "name1='I am a long value'" "name2=two\ words"
  2799.  
  2800.  
  2801.      DDDDUUUUMMMMPPPPIIIINNNNGGGG OOOOUUUUTTTT AAAALLLLLLLL TTTTHHHHEEEE NNNNAAAAMMMMEEEE////VVVVAAAALLLLUUUUEEEE PPPPAAAAIIIIRRRRSSSS
  2802.  
  2803.      The _d_u_m_p() method produces a string consisting of all the query's
  2804.      name/value pairs formatted nicely as a nested list.  This is useful for
  2805.      debugging purposes:
  2806.  
  2807.          print $query->dump
  2808.  
  2809.  
  2810.      Produces something that looks like:
  2811.  
  2812.          <UL>
  2813.          <LI>name1
  2814.              <UL>
  2815.              <LI>value1
  2816.              <LI>value2
  2817.              </UL>
  2818.          <LI>name2
  2819.              <UL>
  2820.              <LI>value1
  2821.              </UL>
  2822.          </UL>
  2823.  
  2824.      You can pass a value of 'true' to _d_u_m_p() in order to get it to print the
  2825.      results out as plain text, suitable for incorporating into a <PRE>
  2826.      section.
  2827.  
  2828.      As a shortcut, as of version 1.56 you can interpolate the entire CGI
  2829.      object into a string and it will be replaced with the a nice HTML dump
  2830.      shown above:
  2831.  
  2832.  
  2833.  
  2834.  
  2835.                                                                        PPPPaaaaggggeeee 44443333
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  2843.  
  2844.  
  2845.  
  2846.          $query=new CGI;
  2847.          print "<H2>Current Values</H2> $query\n";
  2848.  
  2849.  
  2850. FFFFEEEETTTTCCCCHHHHIIIINNNNGGGG EEEENNNNVVVVIIIIRRRROOOONNNNMMMMEEEENNNNTTTT VVVVAAAARRRRIIIIAAAABBBBLLLLEEEESSSS
  2851.      Some of the more useful environment variables can be fetched through this
  2852.      interface.  The methods are as follows:
  2853.  
  2854.      aaaacccccccceeeepppptttt(((())))
  2855.              Return a list of MIME types that the remote browser accepts. If
  2856.              you give this method a single argument corresponding to a MIME
  2857.              type, as in $query->_a_c_c_e_p_t('text/html'), it will return a
  2858.              floating point value corresponding to the browser's preference
  2859.              for this type from 0.0 (don't want) to 1.0.  Glob types (e.g.
  2860.              text/*) in the browser's accept list are handled correctly.
  2861.  
  2862.      rrrraaaawwww____ccccooooooookkkkiiiieeee(((())))
  2863.              Returns the HTTP_COOKIE variable, an HTTP extension implemented
  2864.              by Netscape browsers version 1.1 and higher.  Cookies have a
  2865.              special format, and this method call just returns the raw form
  2866.              (?cookie dough).  See _c_o_o_k_i_e() for ways of setting and retrieving
  2867.              cooked cookies.
  2868.  
  2869.              Called with no parameters, _r_a_w__c_o_o_k_i_e() returns the packed cookie
  2870.              structure.  You can separate it into individual cookies by
  2871.              splitting on the character sequence "; ".  Called with the name
  2872.              of a cookie, retrieves the uuuunnnneeeessssccccaaaappppeeeedddd form of the cookie.  You can
  2873.              use the regular _c_o_o_k_i_e() method to get the names, or use the
  2874.              _r_a_w__f_e_t_c_h() method from the CGI::Cookie module.
  2875.  
  2876.      uuuusssseeeerrrr____aaaaggggeeeennnntttt(((())))
  2877.              Returns the HTTP_USER_AGENT variable.  If you give this method a
  2878.              single argument, it will attempt to pattern match on it, allowing
  2879.              you to do something like $query->_u_s_e_r__a_g_e_n_t(netscape);
  2880.  
  2881.      ppppaaaatttthhhh____iiiinnnnffffoooo(((())))
  2882.              Returns additional path information from the script URL.  E.G.
  2883.              fetching /cgi-bin/your_script/additional/stuff will result in
  2884.              $query->_p_a_t_h__i_n_f_o() returning "additional/stuff".
  2885.  
  2886.              NOTE: The Microsoft Internet Information Server is broken with
  2887.              respect to additional path information.  If you use the Perl DLL
  2888.              library, the IIS server will attempt to execute the additional
  2889.              path information as a Perl script.  If you use the ordinary file
  2890.              associations mapping, the path information will be present in the
  2891.              environment, but incorrect.  The best thing to do is to avoid
  2892.              using additional path information in CGI scripts destined for use
  2893.              with IIS.
  2894.  
  2895.      ppppaaaatttthhhh____ttttrrrraaaannnnssssllllaaaatttteeeedddd(((())))
  2896.              As per _p_a_t_h__i_n_f_o() but returns the additional path information
  2897.              translated into a physical path, e.g.
  2898.  
  2899.  
  2900.  
  2901.                                                                        PPPPaaaaggggeeee 44444444
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  2909.  
  2910.  
  2911.  
  2912.              "/usr/local/etc/httpd/htdocs/additional/stuff".
  2913.  
  2914.              The Microsoft IIS is broken with respect to the translated path
  2915.              as well.
  2916.  
  2917.      rrrreeeemmmmooootttteeee____hhhhoooosssstttt(((())))
  2918.              Returns either the remote host name or IP address.  if the former
  2919.              is unavailable.
  2920.  
  2921. scripts.
  2922.      ssssccccrrrriiiipppptttt____nnnnaaaammmmeeee(((()))) Return the script name as a partial URL, for self-refering
  2923.  
  2924.      rrrreeeeffffeeeerrrreeeerrrr(((())))
  2925.              Return the URL of the page the browser was viewing prior to
  2926.              fetching your script.  Not available for all browsers.
  2927.  
  2928.      aaaauuuutttthhhh____ttttyyyyppppeeee (((())))
  2929.              Return the authorization/verification method in use for this
  2930.              script, if any.
  2931.  
  2932.      sssseeeerrrrvvvveeeerrrr____nnnnaaaammmmeeee (((())))
  2933.              Returns the name of the server, usually the machine's host name.
  2934.  
  2935.      vvvviiiirrrrttttuuuuaaaallll____hhhhoooosssstttt (((())))
  2936.              When using virtual hosts, returns the name of the host that the
  2937.              browser attempted to contact
  2938.  
  2939.      sssseeeerrrrvvvveeeerrrr____ssssooooffffttttwwwwaaaarrrreeee (((())))
  2940.              Returns the server software and version number.
  2941.  
  2942.      rrrreeeemmmmooootttteeee____uuuusssseeeerrrr (((())))
  2943.              Return the authorization/verification name used for user
  2944.              verification, if this script is protected.
  2945.  
  2946.      uuuusssseeeerrrr____nnnnaaaammmmeeee (((())))
  2947.              Attempt to obtain the remote user's name, using a variety of
  2948.              different techniques.  This only works with older browsers such
  2949.              as Mosaic.  Netscape does not reliably report the user name!
  2950.  
  2951.      rrrreeeeqqqquuuueeeesssstttt____mmmmeeeetttthhhhoooodddd(((())))
  2952.              Returns the method used to access your script, usually one of
  2953.              'POST', 'GET' or 'HEAD'.
  2954.  
  2955. UUUUSSSSIIIINNNNGGGG NNNNPPPPHHHH SSSSCCCCRRRRIIIIPPPPTTTTSSSS
  2956.      NPH, or "no-parsed-header", scripts bypass the server completely by
  2957.      sending the complete HTTP header directly to the browser.  This has
  2958.      slight performance benefits, but is of most use for taking advantage of
  2959.      HTTP extensions that are not directly supported by your server, such as
  2960.      server push and PICS headers.
  2961.  
  2962.      Servers use a variety of conventions for designating CGI scripts as NPH.
  2963.      Many Unix servers look at the beginning of the script's name for the
  2964.  
  2965.  
  2966.  
  2967.                                                                        PPPPaaaaggggeeee 44445555
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  2975.  
  2976.  
  2977.  
  2978.      prefix "nph-".  The Macintosh WebSTAR server and Microsoft's Internet
  2979.      Information Server, in contrast, try to decide whether a program is an
  2980.      NPH script by examining the first line of script output.
  2981.  
  2982.      CGI.pm supports NPH scripts with a special NPH mode.  When in this mode,
  2983.      CGI.pm will output the necessary extra header information when the
  2984.      _h_e_a_d_e_r() and _r_e_d_i_r_e_c_t() methods are called.
  2985.  
  2986.      The Microsoft Internet Information Server requires NPH mode.  As of
  2987.      version 2.30, CGI.pm will automatically detect when the script is running
  2988.      under IIS and put itself into this mode.  You do not need to do this
  2989.      manually, although it won't hurt anything if you do.
  2990.  
  2991.      There are a number of ways to put CGI.pm into NPH mode:
  2992.  
  2993.      In the uuuusssseeee statement
  2994.              Simply add the "-nph" pragmato the list of symbols to be imported
  2995.              into your script:
  2996.  
  2997.                    use CGI qw(:standard -nph)
  2998.  
  2999.  
  3000.      By calling the nnnnpppphhhh(((()))) method:
  3001.              Call nnnnpppphhhh(((()))) with a non-zero parameter at any point after using
  3002.              CGI.pm in your program.
  3003.  
  3004.                    CGI->nph(1)
  3005.  
  3006.  
  3007.      By using ----nnnnpppphhhh parameters in the hhhheeeeaaaaddddeeeerrrr(((()))) and rrrreeeeddddiiiirrrreeeecccctttt(((())))  statements:
  3008.  
  3009.                    print $q->header(-nph=>1);
  3010.  
  3011.  
  3012. SSSSeeeerrrrvvvveeeerrrr PPPPuuuusssshhhh
  3013.      CGI.pm provides three simple functions for producing multipart documents
  3014.      of the type needed to implement server push.  These functions were
  3015.      graciously provided by Ed Jordan <ed@fidalgo.net>.  To import these into
  3016.      your namespace, you must import the ":push" set.  You are also advised to
  3017.      put the script into NPH mode and to set $| to 1 to avoid buffering
  3018.      problems.
  3019.  
  3020.      Here is a simple script that demonstrates server push:
  3021.  
  3022.  
  3023.  
  3024.  
  3025.  
  3026.  
  3027.  
  3028.  
  3029.  
  3030.  
  3031.  
  3032.  
  3033.                                                                        PPPPaaaaggggeeee 44446666
  3034.  
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  3041.  
  3042.  
  3043.  
  3044.        #!/usr/local/bin/perl
  3045.        use CGI qw/:push -nph/;
  3046.        $| = 1;
  3047.        print multipart_init(-boundary=>'----------------here we go!');
  3048.        while (1) {
  3049.            print multipart_start(-type=>'text/plain'),
  3050.                  "The current time is ",scalar(localtime),"\n",
  3051.                  multipart_end;
  3052.            sleep 1;
  3053.        }
  3054.  
  3055.      This script initializes server push by calling mmmmuuuullllttttiiiippppaaaarrrrtttt____iiiinnnniiiitttt(((()))).  It then
  3056.      enters an infinite loop in which it begins a new multipart section by
  3057.      calling mmmmuuuullllttttiiiippppaaaarrrrtttt____ssssttttaaaarrrrtttt(((()))), prints the current local time, and ends a
  3058.      multipart section with mmmmuuuullllttttiiiippppaaaarrrrtttt____eeeennnndddd(((()))).  It then sleeps a second, and
  3059.      begins again.
  3060.  
  3061.      multipart_init()         multipart_init(-boundary=>$boundary);
  3062.              Initialize the multipart system.  The -boundary argument
  3063.              specifies what MIME boundary string to use to separate parts of
  3064.              the document.  If not provided, CGI.pm chooses a reasonable
  3065.              boundary for you.
  3066.  
  3067.      multipart_start()
  3068.  
  3069.                multipart_start(-type=>$type)
  3070.  
  3071.              Start a new part of the multipart document using the specified
  3072.              MIME type.  If not specified, text/html is assumed.
  3073.  
  3074.      multipart_end()
  3075.  
  3076.                multipart_end()
  3077.  
  3078.              End a part.  You must remember to call _m_u_l_t_i_p_a_r_t__e_n_d() once for
  3079.              each _m_u_l_t_i_p_a_r_t__s_t_a_r_t().
  3080.  
  3081.              Users interested in server push applications should also have a
  3082.              look at the CGI::Push module.
  3083.  
  3084. AAAAvvvvooooiiiiddddiiiinnnngggg DDDDeeeennnniiiiaaaallll ooooffff SSSSeeeerrrrvvvviiiicccceeee AAAAttttttttaaaacccckkkkssss
  3085.      A potential problem with CGI.pm is that, by default, it attempts to
  3086.      process form POSTings no matter how large they are.  A wily hacker could
  3087.      attack your site by sending a CGI script a huge POST of many megabytes.
  3088.      CGI.pm will attempt to read the entire POST into a variable, growing
  3089.      hugely in size until it runs out of memory.  While the script attempts to
  3090.      allocate the memory the system may slow down dramatically.  This is a
  3091.      form of denial of service attack.
  3092.  
  3093.      Another possible attack is for the remote user to force CGI.pm to accept
  3094.      a huge file upload.  CGI.pm will accept the upload and store it in a
  3095.      temporary directory even if your script doesn't expect to receive an
  3096.  
  3097.  
  3098.  
  3099.                                                                        PPPPaaaaggggeeee 44447777
  3100.  
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  3107.  
  3108.  
  3109.  
  3110.      uploaded file.  CGI.pm will delete the file automatically when it
  3111.      terminates, but in the meantime the remote user may have filled up the
  3112.      server's disk space, causing problems for other programs.
  3113.  
  3114.      The best way to avoid denial of service attacks is to limit the amount of
  3115.      memory, CPU time and disk space that CGI scripts can use.  Some Web
  3116.      servers come with built-in facilities to accomplish this. In other cases,
  3117.      you can use the shell _l_i_m_i_t or _u_l_i_m_i_t commands to put ceilings on CGI
  3118.      resource usage.
  3119.  
  3120.      CGI.pm also has some simple built-in protections against denial of
  3121.      service attacks, but you must activate them before you can use them.
  3122.      These take the form of two global variables in the CGI name space:
  3123.  
  3124.      $$$$CCCCGGGGIIII::::::::PPPPOOOOSSSSTTTT____MMMMAAAAXXXX
  3125.              If set to a non-negative integer, this variable puts a ceiling on
  3126.              the size of POSTings, in bytes.  If CGI.pm detects a POST that is
  3127.              greater than the ceiling, it will immediately exit with an error
  3128.              message.  This value will affect both ordinary POSTs and
  3129.              multipart POSTs, meaning that it limits the maximum size of file
  3130.              uploads as well.  You should set this to a reasonably high value,
  3131.              such as 1 megabyte.
  3132.  
  3133.      $$$$CCCCGGGGIIII::::::::DDDDIIIISSSSAAAABBBBLLLLEEEE____UUUUPPPPLLLLOOOOAAAADDDDSSSS
  3134.              If set to a non-zero value, this will disable file uploads
  3135.              completely.  Other fill-out form values will work as usual.
  3136.  
  3137.              You can use these variables in either of two ways.
  3138.  
  3139.      1111.... OOOOnnnn aaaa ssssccccrrrriiiipppptttt----bbbbyyyy----ssssccccrrrriiiipppptttt bbbbaaaassssiiiissss
  3140.              Set the variable at the top of the script, right after the "use"
  3141.              statement:
  3142.  
  3143.                  use CGI qw/:standard/;
  3144.                  use CGI::Carp 'fatalsToBrowser';
  3145.                  $CGI::POST_MAX=1024 * 100;  # max 100K posts
  3146.                  $CGI::DISABLE_UPLOADS = 1;  # no uploads
  3147.  
  3148.  
  3149.      2222.... GGGGlllloooobbbbaaaallllllllyyyy ffffoooorrrr aaaallllllll ssssccccrrrriiiippppttttssss
  3150.              Open up CGI.pm, find the definitions for $POST_MAX and
  3151.              $DISABLE_UPLOADS, and set them to the desired values.  You'll
  3152.              find them towards the top of the file in a subroutine named
  3153.              _i_n_i_t_i_a_l_i_z_e__g_l_o_b_a_l_s().
  3154.  
  3155.              Since an attempt to send a POST larger than $POST_MAX bytes will
  3156.              cause a fatal error, you might want to use CGI::Carp to echo the
  3157.              fatal error message to the browser window as shown in the example
  3158.              above.  Otherwise the remote user will see only a generic
  3159.              "Internal Server" error message.  See the the _C_G_I::_C_a_r_p manpage
  3160.              manual page for more details.
  3161.  
  3162.  
  3163.  
  3164.  
  3165.                                                                        PPPPaaaaggggeeee 44448888
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  3173.  
  3174.  
  3175.  
  3176. CCCCOOOOMMMMPPPPAAAATTTTIIIIBBBBIIIILLLLIIIITTTTYYYY WWWWIIIITTTTHHHH CCCCGGGGIIII----LLLLIIIIBBBB....PPPPLLLL
  3177.      To make it easier to port existing programs that use cgi-lib.pl the
  3178.      compatibility routine "ReadParse" is provided.  Porting is simple:
  3179.  
  3180.      OLD VERSION
  3181.          require "cgi-lib.pl";
  3182.          &ReadParse;
  3183.          print "The value of the antique is $in{antique}.\n";
  3184.  
  3185.      NEW VERSION
  3186.          use CGI;
  3187.          CGI::ReadParse
  3188.          print "The value of the antique is $in{antique}.\n";
  3189.  
  3190.      CGI.pm's _R_e_a_d_P_a_r_s_e() routine creates a tied variable named %in, which can
  3191.      be accessed to obtain the query variables.  Like ReadParse, you can also
  3192.      provide your own variable.  Infrequently used features of ReadParse, such
  3193.      as the creation of @in and $in variables, are not supported.
  3194.  
  3195.      Once you use ReadParse, you can retrieve the query object itself this
  3196.      way:
  3197.  
  3198.          $q = $in{CGI};
  3199.          print $q->textfield(-name=>'wow',
  3200.                              -value=>'does this really work?');
  3201.  
  3202.      This allows you to start using the more interesting features of CGI.pm
  3203.      without rewriting your old scripts from scratch.
  3204.  
  3205. AAAAUUUUTTTTHHHHOOOORRRR IIIINNNNFFFFOOOORRRRMMMMAAAATTTTIIIIOOOONNNN
  3206.      Copyright 1995-1997, Lincoln D. Stein.  All rights reserved.  It may be
  3207.      used and modified freely, but I do request that this copyright notice
  3208.      remain attached to the file.  You may modify this module as you wish, but
  3209.      if you redistribute a modified version, please attach a note listing the
  3210.      modifications you have made.
  3211.  
  3212.      Address bug reports and comments to:  lstein@genome.wi.mit.edu
  3213.  
  3214. CCCCRRRREEEEDDDDIIIITTTTSSSS
  3215.      Thanks very much to:
  3216.  
  3217.      Matt Heffron (heffron@falstaff.css.beckman.com)
  3218.  
  3219.      James Taylor (james.taylor@srs.gov)
  3220.  
  3221.      Scott Anguish <sanguish@digifix.com>
  3222.  
  3223.      Mike Jewell (mlj3u@virginia.edu)
  3224.  
  3225.      Timothy Shimmin (tes@kbs.citri.edu.au)
  3226.  
  3227.  
  3228.  
  3229.  
  3230.  
  3231.                                                                        PPPPaaaaggggeeee 44449999
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  3239.  
  3240.  
  3241.  
  3242.      Joergen Haegg (jh@axis.se)
  3243.  
  3244.      Laurent Delfosse (delfosse@csgrad1.cs.wvu.edu)
  3245.  
  3246.      Richard Resnick (applepi1@aol.com)
  3247.  
  3248.      Craig Bishop (csb@barwonwater.vic.gov.au)
  3249.  
  3250.      Tony Curtis (tc@vcpc.univie.ac.at)
  3251.  
  3252.      Tim Bunce (Tim.Bunce@ig.co.uk)
  3253.  
  3254.      Tom Christiansen (tchrist@convex.com)
  3255.  
  3256.      Andreas Koenig (k@franz.ww.TU-Berlin.DE)
  3257.  
  3258.      Tim MacKenzie (Tim.MacKenzie@fulcrum.com.au)
  3259.  
  3260.      Kevin B. Hendricks (kbhend@dogwood.tyler.wm.edu)
  3261.  
  3262.      Stephen Dahmen (joyfire@inxpress.net)
  3263.  
  3264.      Ed Jordan (ed@fidalgo.net)
  3265.  
  3266.      David Alan Pisoni (david@cnation.com)
  3267.  
  3268.      Doug MacEachern (dougm@opengroup.org)
  3269.  
  3270.      Robin Houston (robin@oneworld.org)
  3271.  
  3272.      ...and many many more...
  3273.              for suggestions and bug fixes.
  3274.  
  3275. AAAA CCCCOOOOMMMMPPPPLLLLEEEETTTTEEEE EEEEXXXXAAAAMMMMPPPPLLLLEEEE OOOOFFFF AAAA SSSSIIIIMMMMPPPPLLLLEEEE FFFFOOOORRRRMMMM----BBBBAAAASSSSEEEEDDDD SSSSCCCCRRRRIIIIPPPPTTTT
  3276.              #!/usr/local/bin/perl
  3277.  
  3278.              use CGI;
  3279.  
  3280.              $query = new CGI;
  3281.  
  3282.  
  3283.  
  3284.  
  3285.  
  3286.  
  3287.  
  3288.  
  3289.  
  3290.  
  3291.  
  3292.  
  3293.  
  3294.  
  3295.  
  3296.  
  3297.                                                                        PPPPaaaaggggeeee 55550000
  3298.  
  3299.  
  3300.  
  3301.  
  3302.  
  3303.  
  3304. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  3305.  
  3306.  
  3307.  
  3308.              print $query->header;
  3309.              print $query->start_html("Example CGI.pm Form");
  3310.              print "<H1> Example CGI.pm Form</H1>\n";
  3311.              &print_prompt($query);
  3312.              &do_work($query);
  3313.              &print_tail;
  3314.              print $query->end_html;
  3315.  
  3316.              sub print_prompt {
  3317.                 my($query) = @_;
  3318.  
  3319.                 print $query->startform;
  3320.                 print "<EM>What's your name?</EM><BR>";
  3321.                 print $query->textfield('name');
  3322.                 print $query->checkbox('Not my real name');
  3323.  
  3324.                 print "<P><EM>Where can you find English Sparrows?</EM><BR>";
  3325.                 print $query->checkbox_group(
  3326.                                       -name=>'Sparrow locations',
  3327.                                       -values=>[England,France,Spain,Asia,Hoboken],
  3328.                                       -linebreak=>'yes',
  3329.                                       -defaults=>[England,Asia]);
  3330.  
  3331.                 print "<P><EM>How far can they fly?</EM><BR>",
  3332.                      $query->radio_group(
  3333.                              -name=>'how far',
  3334.                              -values=>['10 ft','1 mile','10 miles','real far'],
  3335.                              -default=>'1 mile');
  3336.  
  3337.                 print "<P><EM>What's your favorite color?</EM>  ";
  3338.                 print $query->popup_menu(-name=>'Color',
  3339.                                          -values=>['black','brown','red','yellow'],
  3340.                                          -default=>'red');
  3341.  
  3342.                 print $query->hidden('Reference','Monty Python and the Holy Grail');
  3343.  
  3344.                 print "<P><EM>What have you got there?</EM><BR>";
  3345.                 print $query->scrolling_list(
  3346.                               -name=>'possessions',
  3347.                               -values=>['A Coconut','A Grail','An Icon',
  3348.                                         'A Sword','A Ticket'],
  3349.                               -size=>5,
  3350.                               -multiple=>'true');
  3351.  
  3352.                 print "<P><EM>Any parting comments?</EM><BR>";
  3353.                 print $query->textarea(-name=>'Comments',
  3354.                                        -rows=>10,
  3355.                                        -columns=>50);
  3356.  
  3357.                 print "<P>",$query->reset;
  3358.                 print $query->submit('Action','Shout');
  3359.                 print $query->submit('Action','Scream');
  3360.  
  3361.  
  3362.  
  3363.                                                                        PPPPaaaaggggeeee 55551111
  3364.  
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  3371.  
  3372.  
  3373.  
  3374.                 print $query->endform;
  3375.                 print "<HR>\n";
  3376.              }
  3377.  
  3378.              sub do_work {
  3379.                 my($query) = @_;
  3380.                 my(@values,$key);
  3381.  
  3382.                 print "<H2>Here are the current settings in this form</H2>";
  3383.  
  3384.                 foreach $key ($query->param) {
  3385.                    print "<STRONG>$key</STRONG> -> ";
  3386.                    @values = $query->param($key);
  3387.                    print join(", ",@values),"<BR>\n";
  3388.                }
  3389.              }
  3390.  
  3391.              sub print_tail {
  3392.                 print <<END;
  3393.              <HR>
  3394.              <ADDRESS>Lincoln D. Stein</ADDRESS><BR>
  3395.              <A HREF="/">Home Page</A>
  3396.              END
  3397.              }
  3398.  
  3399.  
  3400. BBBBUUUUGGGGSSSS
  3401.      This module has grown large and monolithic.  Furthermore it's doing many
  3402.      things, such as handling URLs, parsing CGI input, writing HTML, etc.,
  3403.      that are also done in the LWP modules. It should be discarded in favor of
  3404.      the CGI::* modules, but somehow I continue to work on it.
  3405.  
  3406.      Note that the code is truly contorted in order to avoid spurious warnings
  3407.      when programs are run with the ----wwww switch.
  3408.  
  3409. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  3410.      the _C_G_I::_C_a_r_p manpage, the _U_R_I::_U_R_L manpage, the _C_G_I::_R_e_q_u_e_s_t manpage,
  3411.      the _C_G_I::_M_i_n_i_S_v_r manpage, the _C_G_I::_B_a_s_e manpage, the _C_G_I::_F_o_r_m manpage,
  3412.      the _C_G_I::_A_p_a_c_h_e manpage, the _C_G_I::_S_w_i_t_c_h manpage, the _C_G_I::_P_u_s_h manpage,
  3413.      the _C_G_I::_F_a_s_t manpage
  3414.  
  3415.  
  3416.  
  3417.  
  3418.  
  3419.  
  3420.  
  3421.  
  3422.  
  3423.  
  3424.  
  3425.  
  3426.  
  3427.  
  3428.  
  3429.                                                                        PPPPaaaaggggeeee 55552222
  3430.  
  3431.  
  3432.  
  3433.  
  3434.  
  3435.  
  3436. CCCCGGGGIIII((((3333))))                                                                  CCCCGGGGIIII((((3333))))
  3437.  
  3438.  
  3439.  
  3440.  
  3441.  
  3442.  
  3443.  
  3444.  
  3445.  
  3446.  
  3447.  
  3448.  
  3449.  
  3450.  
  3451.  
  3452.  
  3453.  
  3454.  
  3455.  
  3456.  
  3457.  
  3458.  
  3459.  
  3460.  
  3461.  
  3462.  
  3463.  
  3464.  
  3465.  
  3466.  
  3467.  
  3468.  
  3469.  
  3470.  
  3471.  
  3472.  
  3473.  
  3474.  
  3475.  
  3476.  
  3477.  
  3478.  
  3479.  
  3480.  
  3481.  
  3482.  
  3483.  
  3484.  
  3485.  
  3486.  
  3487.  
  3488.  
  3489.  
  3490.  
  3491.  
  3492.                                                                        PPPPaaaaggggeeee 55553333
  3493.  
  3494.  
  3495.  
  3496.  
  3497.  
  3498.  
  3499.